test_utils

package
v0.0.0-...-1350c8b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 21, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AdminAddr   = "0xf8d6e0586b0a20c7"
	UserOneAddr = "0x01cf0e2f2f715450"

	DefaultCommunity = models.Community{
		Name:                   "TestDAO",
		Category:               &category,
		Body:                   &body,
		Creator_addr:           "<replace>",
		Logo:                   &logo,
		Slug:                   &slug,
		Strategies:             &strategies,
		Only_authors_to_submit: &onlyAuthors,
		Proposal_threshold:     &thresholdZero,
	}

	FailStrategyCommunity = models.Community{
		Name:                   "TestDAO",
		Category:               &category,
		Body:                   &body,
		Creator_addr:           "<replace>",
		Logo:                   &logo,
		Slug:                   &slug,
		Strategies:             &failStrategies,
		Only_authors_to_submit: &onlyAuthors,
	}

	FailThresholdCommunity = models.Community{
		Name:                   "TestDAO",
		Category:               &category,
		Body:                   &body,
		Creator_addr:           "<replace>",
		Logo:                   &logo,
		Slug:                   &slug,
		Strategies:             &strategies,
		Only_authors_to_submit: &notOnlyAuthors,
		Proposal_threshold:     &thresholdZero,
	}

	NilStrategyCommunity = models.Community{
		Name:                   "TestDAO",
		Category:               &category,
		Body:                   &body,
		Creator_addr:           "<replace>",
		Logo:                   &logo,
		Slug:                   &slug,
		Strategies:             nil,
		Only_authors_to_submit: &onlyAuthors,
	}

	CommunityWithThreshold = models.Community{
		Name:                   "With Threshold",
		Category:               &category,
		Body:                   &body,
		Creator_addr:           "<replace>",
		Logo:                   &logo,
		Slug:                   &slug,
		Proposal_threshold:     &proposal_threshold,
		Contract_name:          &flowContractName,
		Contract_addr:          &flowContractAddr,
		Public_path:            &flowPublicPath,
		Only_authors_to_submit: &notOnlyAuthors,
	}

	CommunityWithNFT = models.Community{
		Name:                   "With NFT Contract",
		Category:               &category,
		Body:                   &body,
		Creator_addr:           "<replace>",
		Logo:                   &logo,
		Slug:                   &slug,
		Contract_name:          &exampleNFTName,
		Contract_addr:          &exampleNFTAddr,
		Public_path:            &exampleNFTPublicPath,
		Only_authors_to_submit: &notOnlyAuthors,
	}

	UpdatedCommunity = models.Community{
		Name:                     nameUpdated,
		Logo:                     &logoUpdated,
		Banner_img_url:           &banner,
		Website_url:              &website,
		Twitter_url:              &twitter,
		Github_url:               &github,
		Discord_url:              &discord,
		Instagram_url:            &instagram,
		Strategies:               &updatedStrategies,
		Terms_and_conditions_url: &termsAndConditions,
		Only_authors_to_submit:   &notOnlyAuthors,
		Proposal_threshold:       &thresholdOne,
	}
)
View Source
var DefaultAuthor = models.CommunityUser{
	Community_id: 1,
	Addr:         "0x01cf0e2f2f715450",
	User_type:    "author",
}
View Source
var DefaultListAddresses = []string{"0x01", "0x02", "0x03"}
View Source
var DefaultListPayload = models.ListPayload{
	List: DefaultListStruct,
}
View Source
var DefaultListStruct = models.List{
	Addresses: DefaultListAddresses,
	List_type: &DefaultListType,
}
View Source
var DefaultListType = "block"
View Source
var (
	DefaultProposalStruct = models.Proposal{
		Name: "Test Proposal",
		Body: &proposalBody,
		Choices: []shared.Choice{
			{Choice_text: "a"},
			{Choice_text: "b"},
		},
		Creator_addr: ServiceAccountAddress,
		Strategy:     &tokenWeightedDefault,
		Status:       &published,
		Block_height: &blockHeight,
	}
)
View Source
var InvalidServiceAccountKey = "5687d75f957bf64591b55eb19227706e3c8712c1387225b87aff072585ea8e51"
View Source
var ServiceAccountAddress = "0xf8d6e0586b0a20c7"

Valid/Invalid service account key is based on the flow.json file in this repo, and assumes you are running the emulator from this repo

View Source
var ValidServiceAccountKey = "63bff10bd6186b7d97c8e2898941c93d5d33a830b0ac9b758e216024b7bf7957"

Functions

This section is empty.

Types

type OverflowTestUtils

type OverflowTestUtils struct {
	O       *overflow.OverflowState
	T       *testing.T
	A       *server.App
	Adapter *shared.FlowAdapter
}

func NewOverflowTest

func NewOverflowTest(t *testing.T, a *server.App) *OverflowTestUtils

func (*OverflowTestUtils) AddActiveProposals

func (otu *OverflowTestUtils) AddActiveProposals(cId int, count int) []int

func (*OverflowTestUtils) AddActiveProposalsWithStartTimeNow

func (otu *OverflowTestUtils) AddActiveProposalsWithStartTimeNow(cId int, count int) []int

func (*OverflowTestUtils) AddAddressesToListAPI

func (otu *OverflowTestUtils) AddAddressesToListAPI(listId int, payload *models.ListPayload) *httptest.ResponseRecorder

func (*OverflowTestUtils) AddCommunities

func (otu *OverflowTestUtils) AddCommunities(count int, category string) []int

func (*OverflowTestUtils) AddCommunitiesWithNFTContract

func (otu *OverflowTestUtils) AddCommunitiesWithNFTContract(count int, signer string) ([]int, *models.Community)

func (*OverflowTestUtils) AddCommunitiesWithUsers

func (otu *OverflowTestUtils) AddCommunitiesWithUsers(count int, signer string) []int

func (*OverflowTestUtils) AddCommunitiesWithUsersAndThreshold

func (otu *OverflowTestUtils) AddCommunitiesWithUsersAndThreshold(count int, signer string) []int

func (*OverflowTestUtils) AddDummyVotesAndBalances

func (otu *OverflowTestUtils) AddDummyVotesAndBalances(votes []*models.VoteWithBalance) error

func (*OverflowTestUtils) AddDummyVotesAndNFTs

func (otu *OverflowTestUtils) AddDummyVotesAndNFTs(votes []*models.VoteWithBalance)

func (*OverflowTestUtils) AddLists

func (otu *OverflowTestUtils) AddLists(cId int, count int) []int

func (*OverflowTestUtils) AddProposals

func (otu *OverflowTestUtils) AddProposals(cId int, count int) []int

func (*OverflowTestUtils) AddProposalsForStrategy

func (otu *OverflowTestUtils) AddProposalsForStrategy(cId int, strategy string, count int) ([]int, []*models.Proposal)

func (*OverflowTestUtils) AddVotes

func (otu *OverflowTestUtils) AddVotes(pId int, count int)

func (*OverflowTestUtils) CreateCommunityAPI

func (otu *OverflowTestUtils) CreateCommunityAPI(community *models.Community) *httptest.ResponseRecorder

func (*OverflowTestUtils) CreateCommunityDB

func (otu *OverflowTestUtils) CreateCommunityDB(community *models.Community) error

func (*OverflowTestUtils) CreateCommunityUserAPI

func (otu *OverflowTestUtils) CreateCommunityUserAPI(id int, payload *models.CommunityUserPayload) *httptest.ResponseRecorder

func (*OverflowTestUtils) CreateListAPI

func (otu *OverflowTestUtils) CreateListAPI(payload *models.ListPayload) *httptest.ResponseRecorder

func (*OverflowTestUtils) CreateNFTVote

func (otu *OverflowTestUtils) CreateNFTVote(v models.Vote, ids []interface{}, contract *shared.Contract) models.VoteWithBalance

func (*OverflowTestUtils) CreateProposalAPI

func (otu *OverflowTestUtils) CreateProposalAPI(proposal *models.Proposal) *httptest.ResponseRecorder

func (*OverflowTestUtils) CreateVoteAPI

func (otu *OverflowTestUtils) CreateVoteAPI(proposalId int, payload *models.Vote) *httptest.ResponseRecorder

func (*OverflowTestUtils) DeleteUserFromCommunityAPI

func (otu *OverflowTestUtils) DeleteUserFromCommunityAPI(id int, addr string, userType string, payload *models.CommunityUserPayload) *httptest.ResponseRecorder

func (*OverflowTestUtils) ExecuteRequest

func (otu *OverflowTestUtils) ExecuteRequest(req *http.Request) *httptest.ResponseRecorder

func (*OverflowTestUtils) GenerateBlockListPayload

func (otu *OverflowTestUtils) GenerateBlockListPayload(signer string, list *models.List) *models.ListPayload

func (*OverflowTestUtils) GenerateBlockListStruct

func (otu *OverflowTestUtils) GenerateBlockListStruct(communityId int) *models.List

func (*OverflowTestUtils) GenerateCancelProposalStruct

func (otu *OverflowTestUtils) GenerateCancelProposalStruct(
	signer string,
	proposalId int,
) *models.UpdateProposalRequestPayload

func (*OverflowTestUtils) GenerateCheatVote

func (otu *OverflowTestUtils) GenerateCheatVote(proposalId int, count int) *[]models.VoteWithBalance

func (*OverflowTestUtils) GenerateClosedProposalStruct

func (otu *OverflowTestUtils) GenerateClosedProposalStruct(
	signer string,
	proposalId int,
) *models.UpdateProposalRequestPayload

func (*OverflowTestUtils) GenerateCommunityPayload

func (otu *OverflowTestUtils) GenerateCommunityPayload(signer string, payload *models.Community) *models.Community

func (*OverflowTestUtils) GenerateCommunityStruct

func (otu *OverflowTestUtils) GenerateCommunityStruct(accountName, category string) *models.Community

func (*OverflowTestUtils) GenerateCommunityUserPayload

func (otu *OverflowTestUtils) GenerateCommunityUserPayload(signer string, user *models.CommunityUser) *models.CommunityUserPayload

func (*OverflowTestUtils) GenerateCommunityUserStruct

func (otu *OverflowTestUtils) GenerateCommunityUserStruct(accountName string, userType string) *models.CommunityUser

func (*OverflowTestUtils) GenerateCommunityWithNFTContractStruct

func (otu *OverflowTestUtils) GenerateCommunityWithNFTContractStruct(accountName string) *models.Community

func (*OverflowTestUtils) GenerateCommunityWithThresholdStruct

func (otu *OverflowTestUtils) GenerateCommunityWithThresholdStruct(accountName string) *models.Community

func (*OverflowTestUtils) GenerateCompositeSignatures

func (otu *OverflowTestUtils) GenerateCompositeSignatures(account string, message string) *[]shared.CompositeSignature

func (*OverflowTestUtils) GenerateEarlyVoteAchievements

func (otu *OverflowTestUtils) GenerateEarlyVoteAchievements(communityId int, numProposals int, numUsers int) []int

func (*OverflowTestUtils) GenerateFailStrategyCommunityStruct

func (otu *OverflowTestUtils) GenerateFailStrategyCommunityStruct(accountName string) *models.Community

func (*OverflowTestUtils) GenerateFailThresholdCommunityStruct

func (otu *OverflowTestUtils) GenerateFailThresholdCommunityStruct(accountName string) *models.Community

func (*OverflowTestUtils) GenerateListOfVotes

func (otu *OverflowTestUtils) GenerateListOfVotes(proposalId int, count int) []*models.VoteWithBalance

func (*OverflowTestUtils) GenerateListOfVotesWithNFTs

func (otu *OverflowTestUtils) GenerateListOfVotesWithNFTs(
	proposalId int,
	count int,
	contract *shared.Contract,
) ([]*models.VoteWithBalance, error)

func (*OverflowTestUtils) GenerateMultiStreakAchievements

func (otu *OverflowTestUtils) GenerateMultiStreakAchievements(communityId int, streakLengths []int)

func (*OverflowTestUtils) GenerateNilStrategyCommunityStruct

func (otu *OverflowTestUtils) GenerateNilStrategyCommunityStruct(accountName string) *models.Community

func (*OverflowTestUtils) GenerateProposalPayload

func (otu *OverflowTestUtils) GenerateProposalPayload(signer string, proposal *models.Proposal) *models.Proposal

func (*OverflowTestUtils) GenerateProposalStruct

func (otu *OverflowTestUtils) GenerateProposalStruct(signer string, communityId int) *models.Proposal

func (*OverflowTestUtils) GenerateSingleStreakAchievements

func (otu *OverflowTestUtils) GenerateSingleStreakAchievements(communityId int, streakLengths []int)

func (*OverflowTestUtils) GenerateSingleVoteWithNFT

func (otu *OverflowTestUtils) GenerateSingleVoteWithNFT(
	proposalId int,
	accountNumber int,
	contract *shared.Contract,
) (*models.VoteWithBalance, error)

func (*OverflowTestUtils) GenerateUpdateListPayload

func (otu *OverflowTestUtils) GenerateUpdateListPayload(listId, communityId int, signer string) *models.ListPayload

func (*OverflowTestUtils) GenerateValidVotePayload

func (otu *OverflowTestUtils) GenerateValidVotePayload(accountName string, proposalId int, choice string) *models.Vote

func (*OverflowTestUtils) GenerateVotes

func (otu *OverflowTestUtils) GenerateVotes(communityId int, numProposals int, numUsers int)

func (*OverflowTestUtils) GenerateWinningVoteAchievement

func (otu *OverflowTestUtils) GenerateWinningVoteAchievement(communityId int, strategy string) int

func (*OverflowTestUtils) GetCommunitiesForHomepageAPI

func (otu *OverflowTestUtils) GetCommunitiesForHomepageAPI() *httptest.ResponseRecorder

func (*OverflowTestUtils) GetCommunityAPI

func (otu *OverflowTestUtils) GetCommunityAPI(id int) *httptest.ResponseRecorder

func (*OverflowTestUtils) GetCommunityActiveStrategies

func (otu *OverflowTestUtils) GetCommunityActiveStrategies(id int) *httptest.ResponseRecorder

func (*OverflowTestUtils) GetCommunityLeaderboardAPI

func (otu *OverflowTestUtils) GetCommunityLeaderboardAPI(id int) *httptest.ResponseRecorder

func (*OverflowTestUtils) GetCommunityLeaderboardAPIWithCurrentUser

func (otu *OverflowTestUtils) GetCommunityLeaderboardAPIWithCurrentUser(id int, addr string) *httptest.ResponseRecorder

func (*OverflowTestUtils) GetCommunityLeaderboardAPIWithPaging

func (otu *OverflowTestUtils) GetCommunityLeaderboardAPIWithPaging(id, start, count int) *httptest.ResponseRecorder

func (*OverflowTestUtils) GetCommunityUsersAPI

func (otu *OverflowTestUtils) GetCommunityUsersAPI(id int) *httptest.ResponseRecorder

func (*OverflowTestUtils) GetCommunityUsersAPIByType

func (otu *OverflowTestUtils) GetCommunityUsersAPIByType(id int, userType string) *httptest.ResponseRecorder

func (*OverflowTestUtils) GetListByIdAPI

func (otu *OverflowTestUtils) GetListByIdAPI(listId int) *httptest.ResponseRecorder

func (*OverflowTestUtils) GetListsForCommunityAPI

func (otu *OverflowTestUtils) GetListsForCommunityAPI(communityId int) *httptest.ResponseRecorder

func (*OverflowTestUtils) GetProposalByIdAPI

func (otu *OverflowTestUtils) GetProposalByIdAPI(communityId int, proposalId int) *httptest.ResponseRecorder

func (*OverflowTestUtils) GetProposalResultsAPI

func (otu *OverflowTestUtils) GetProposalResultsAPI(proposalId int) *httptest.ResponseRecorder

func (*OverflowTestUtils) GetProposalsForCommunityAPI

func (otu *OverflowTestUtils) GetProposalsForCommunityAPI(communityId int) *httptest.ResponseRecorder

func (*OverflowTestUtils) GetSearchCommunitiesAPI

func (otu *OverflowTestUtils) GetSearchCommunitiesAPI(filters []string, text string, count *int) *httptest.ResponseRecorder

func (*OverflowTestUtils) GetUserCommunitiesAPI

func (otu *OverflowTestUtils) GetUserCommunitiesAPI(addr string) *httptest.ResponseRecorder

func (*OverflowTestUtils) GetVoteForProposalByAccountNameAPI

func (otu *OverflowTestUtils) GetVoteForProposalByAccountNameAPI(proposalId int, accountName string) *httptest.ResponseRecorder

func (*OverflowTestUtils) GetVoteForProposalByAddressAPI

func (otu *OverflowTestUtils) GetVoteForProposalByAddressAPI(proposalId int, address string) *httptest.ResponseRecorder

func (*OverflowTestUtils) GetVotesForAddressAPI

func (otu *OverflowTestUtils) GetVotesForAddressAPI(address string, proposalIds []int) *httptest.ResponseRecorder

func (*OverflowTestUtils) GetVotesForProposalAPI

func (otu *OverflowTestUtils) GetVotesForProposalAPI(proposalId int) *httptest.ResponseRecorder

func (*OverflowTestUtils) MakeFeaturedCommunity

func (otu *OverflowTestUtils) MakeFeaturedCommunity(cId int)

func (*OverflowTestUtils) MintNFT

func (otu *OverflowTestUtils) MintNFT(p shared.MintParams)

func (*OverflowTestUtils) RemoveAddressesFromListAPI

func (otu *OverflowTestUtils) RemoveAddressesFromListAPI(listId int, payload *models.ListPayload) *httptest.ResponseRecorder

func (*OverflowTestUtils) ResolveUser

func (otu *OverflowTestUtils) ResolveUser(user int) string

func (*OverflowTestUtils) SetTest

func (otu *OverflowTestUtils) SetTest(t *testing.T) *OverflowTestUtils

func (*OverflowTestUtils) SetupAccountForFlow

func (otu *OverflowTestUtils) SetupAccountForFlow(account string)

func (*OverflowTestUtils) SetupAccountForNFTs

func (otu *OverflowTestUtils) SetupAccountForNFTs(account string)

func (*OverflowTestUtils) SetupToReceiveRoyalty

func (otu *OverflowTestUtils) SetupToReceiveRoyalty(account string)

func (*OverflowTestUtils) TransferNFT

func (otu *OverflowTestUtils) TransferNFT(signer, recipient string, id uint64)

func (*OverflowTestUtils) UpdateCommunityAPI

func (otu *OverflowTestUtils) UpdateCommunityAPI(id int, payload *models.Community) *httptest.ResponseRecorder

func (*OverflowTestUtils) UpdateProposalAPI

func (otu *OverflowTestUtils) UpdateProposalAPI(
	proposalId int,
	payload *models.UpdateProposalRequestPayload,
) *httptest.ResponseRecorder

func (*OverflowTestUtils) UpdateProposalEndTime

func (otu *OverflowTestUtils) UpdateProposalEndTime(pId int, endTime time.Time)

type PaginatedResponseSearch

type PaginatedResponseSearch struct {
	Filters []SearchFilter                 `json:"filters"`
	Results PaginatedResponseWithCommunity `json:"results"`
}

type PaginatedResponseWithCommunity

type PaginatedResponseWithCommunity struct {
	Data         []models.Community `json:"data"`
	Start        int                `json:"start"`
	Count        int                `json:"count"`
	TotalRecords int                `json:"totalRecords"`
	Next         int                `json:"next"`
}

type PaginatedResponseWithLeaderboardUser

type PaginatedResponseWithLeaderboardUser struct {
	Data         models.LeaderboardPayload `json:"data"`
	Start        int                       `json:"start"`
	Count        int                       `json:"count"`
	TotalRecords int                       `json:"totalRecords"`
	Next         int                       `json:"next"`
}

type PaginatedResponseWithUser

type PaginatedResponseWithUser struct {
	Data         []models.CommunityUser `json:"data"`
	Start        int                    `json:"start"`
	Count        int                    `json:"count"`
	TotalRecords int                    `json:"totalRecords"`
	Next         int                    `json:"next"`
}

type PaginatedResponseWithUserCommunity

type PaginatedResponseWithUserCommunity struct {
	Data         []models.UserCommunity `json:"data"`
	Start        int                    `json:"start"`
	Count        int                    `json:"count"`
	TotalRecords int                    `json:"totalRecords"`
	Next         int                    `json:"next"`
}

type PaginatedResponseWithUserType

type PaginatedResponseWithUserType struct {
	Data         []models.CommunityUserType `json:"data"`
	Start        int                        `json:"start"`
	Count        int                        `json:"count"`
	TotalRecords int                        `json:"totalRecords"`
	Next         int                        `json:"next"`
}

type PaginatedResponseWithVotes

type PaginatedResponseWithVotes struct {
	Data         []models.VoteWithBalance `json:"data"`
	Start        int                      `json:"start"`
	Count        int                      `json:"count"`
	TotalRecords int                      `json:"totalRecords"`
	Next         int                      `json:"next"`
}

type SearchFilter

type SearchFilter struct {
	Text   string `json:"text"`
	Amount int    `json:"amount"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL