Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added createTestUsers and updated deps #173

Merged
merged 4 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ require (
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.1.0
github.com/hashicorp/go-multierror v1.1.1
github.com/hexops/autogold v1.3.1
github.com/onflow/cadence v1.0.0-preview.38
github.com/onflow/cadence v1.0.0-preview.39
github.com/onflow/flixkit-go v1.2.1-cadence-v1-preview.18
github.com/onflow/flow-emulator v1.0.0-preview.35
github.com/onflow/flow-go v0.36.2-0.20240717214129-9ea6faeee3e7
github.com/onflow/flow-go-sdk v1.0.0-preview.41
github.com/onflow/flowkit/v2 v2.0.0-stable-cadence-alpha.26
github.com/onflow/flow-emulator v1.0.0-preview.36
github.com/onflow/flow-go v0.36.4-0.20240724205438-14f9fddeda2b
github.com/onflow/flow-go-sdk v1.0.0-preview.42
github.com/onflow/flowkit/v2 v2.0.0-stable-cadence-alpha.29
github.com/pkg/errors v0.9.1
github.com/rs/zerolog v1.29.1
github.com/sanity-io/litter v1.5.5
Expand Down Expand Up @@ -68,6 +68,7 @@ require (
github.com/dgraph-io/ristretto v0.1.0 // indirect
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/ef-ds/deque v1.0.4 // indirect
github.com/ethereum/c-kzg-4844 v1.0.0 // indirect
Expand All @@ -81,6 +82,9 @@ require (
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect
github.com/getsentry/sentry-go v0.27.0 // indirect
github.com/glebarez/go-sqlite v1.22.0 // indirect
github.com/go-kit/kit v0.12.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.5.1 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
Expand Down Expand Up @@ -133,6 +137,8 @@ require (
github.com/kr/text v0.2.0 // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
github.com/libp2p/go-libp2p v0.32.2 // indirect
github.com/libp2p/go-libp2p-pubsub v0.10.0 // indirect
github.com/libp2p/go-msgio v0.3.0 // indirect
github.com/lmars/go-slip10 v0.0.0-20190606092855-400ba44fee12 // indirect
github.com/logrusorgru/aurora v2.0.3+incompatible // indirect
github.com/logrusorgru/aurora/v4 v4.0.0 // indirect
Expand All @@ -157,15 +163,16 @@ require (
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/onflow/atree v0.7.0-rc.2 // indirect
github.com/onflow/crypto v0.25.1 // indirect
github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.0 // indirect
github.com/onflow/flow-core-contracts/lib/go/templates v1.3.0 // indirect
github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.1 // indirect
github.com/onflow/flow-core-contracts/lib/go/templates v1.3.1 // indirect
github.com/onflow/flow-ft/lib/go/contracts v1.0.0 // indirect
github.com/onflow/flow-ft/lib/go/templates v1.0.0 // indirect
github.com/onflow/flow-nft/lib/go/contracts v1.2.1 // indirect
github.com/onflow/flow-nft/lib/go/templates v1.2.0 // indirect
github.com/onflow/flow/protobuf/go/flow v0.4.5 // indirect
github.com/onflow/go-ethereum v1.14.7 // indirect
github.com/onflow/sdks v0.6.0-preview.1 // indirect
github.com/onflow/wal v1.0.2 // indirect
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/pierrec/lz4 v2.6.1+incompatible // indirect
Expand Down
34 changes: 18 additions & 16 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1074,8 +1074,6 @@ github.com/bits-and-blooms/bitset v1.5.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edY
github.com/bits-and-blooms/bitset v1.7.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA=
github.com/bits-and-blooms/bitset v1.10.0 h1:ePXTeiPEazB5+opbv5fr8umg2R/1NlzgDsyepwsSr88=
github.com/bits-and-blooms/bitset v1.10.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8=
github.com/bjartek/underflow v1.5.0 h1:0EJK6DmueoO+ffKzH8uhXkuVPL6FHiAQdzBsfrQ9s5Q=
github.com/bjartek/underflow v1.5.0/go.mod h1:M+rSteYN7KtCDUIjILxxUJRFyhpgOM1WFujJzyTDIP4=
github.com/bjartek/underflow v1.6.0 h1:Ln5dUBpn8Xk1+1ljKXcV23LocGKjHz8mJpD+kX2YutY=
github.com/bjartek/underflow v1.6.0/go.mod h1:3K53iX65TzDBnTOaZt7yXmiFfYiIFtFfECn6xrCQWVA=
github.com/bmizerany/pat v0.0.0-20170815010413-6226ea591a40/go.mod h1:8rLXio+WjiTceGBHIoTvn60HIbs7Hm7bcHjyrSqYB9c=
Expand Down Expand Up @@ -1585,6 +1583,8 @@ github.com/googleapis/go-type-adapters v1.0.0/go.mod h1:zHW75FOG2aur7gAO2B+MLby+
github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
Expand Down Expand Up @@ -1822,6 +1822,8 @@ github.com/libp2p/go-libp2p-record v0.2.0 h1:oiNUOCWno2BFuxt3my4i1frNrt7PerzB3qu
github.com/libp2p/go-libp2p-record v0.2.0/go.mod h1:I+3zMkvvg5m2OcSdoL0KPljyJyvNDFGKX7QdlpYUcwk=
github.com/libp2p/go-libp2p-routing-helpers v0.7.3 h1:u1LGzAMVRK9Nqq5aYDVOiq/HaB93U9WWczBzGyAC5ZY=
github.com/libp2p/go-libp2p-routing-helpers v0.7.3/go.mod h1:cN4mJAD/7zfPKXBcs9ze31JGYAZgzdABEm+q/hkswb8=
github.com/libp2p/go-libp2p-testing v0.12.0 h1:EPvBb4kKMWO29qP4mZGyhVzUyR25dvfUIK5WDu6iPUA=
github.com/libp2p/go-libp2p-testing v0.12.0/go.mod h1:KcGDRXyN7sQCllucn1cOOS+Dmm7ujhfEyXQL5lvkcPg=
github.com/libp2p/go-msgio v0.3.0 h1:mf3Z8B1xcFN314sWX+2vOTShIE0Mmn2TXn3YCUQGNj0=
github.com/libp2p/go-msgio v0.3.0/go.mod h1:nyRM819GmVaF9LX3l03RMh10QdOroF++NBbxAb0mmDM=
github.com/libp2p/go-nat v0.2.0 h1:Tyz+bUFAYqGyJ/ppPPymMGbIgNRH+WqC5QrT5fKrrGk=
Expand Down Expand Up @@ -1966,37 +1968,37 @@ github.com/onflow/atree v0.6.1-0.20230711151834-86040b30171f/go.mod h1:xvP61FoOs
github.com/onflow/atree v0.7.0-rc.2 h1:mZmVrl/zPlfI44EjV3FdR2QwIqT8nz1sCONUBFcML/U=
github.com/onflow/atree v0.7.0-rc.2/go.mod h1:xvP61FoOs95K7IYdIYRnNcYQGf4nbF/uuJ0tHf4DRuM=
github.com/onflow/cadence v1.0.0-M3/go.mod h1:odXGZZ/wGNA5mwT8bC9v8u8EXACHllB2ABSZK65TGL8=
github.com/onflow/cadence v1.0.0-preview.38 h1:Ag3V1YCErma9ZF+eaNq602Vv2lBI3ScaMUcUOFj81GQ=
github.com/onflow/cadence v1.0.0-preview.38/go.mod h1:jOwvPSSLTr9TvaKMs7KKiBYMmpdpNNAFxBsjMlrqVD0=
github.com/onflow/cadence v1.0.0-preview.39 h1:BDx+hO4THUW6cDN11tqVtBx8hFSUErjQkw/WDAGs0C4=
github.com/onflow/cadence v1.0.0-preview.39/go.mod h1:jOwvPSSLTr9TvaKMs7KKiBYMmpdpNNAFxBsjMlrqVD0=
github.com/onflow/crypto v0.25.0/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlpCLYyVI=
github.com/onflow/crypto v0.25.1 h1:0txy2PKPMM873JbpxQNbJmuOJtD56bfs48RQfm0ts5A=
github.com/onflow/crypto v0.25.1/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlpCLYyVI=
github.com/onflow/flixkit-go v1.2.1-cadence-v1-preview.18 h1:3IznBzxdXKrVJ8YDaA2dSQD2HQeWmsL3HsjZY86L+5o=
github.com/onflow/flixkit-go v1.2.1-cadence-v1-preview.18/go.mod h1:dZqcdrsDdvBs5433bkXC8KN0l/jCamerWcmaB1P7YM4=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.0 h1:cq3RfBr9TnTSnsGlUHMjMGZib24Horfb1XJqMpkN5ew=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.0/go.mod h1:u/mkP/B+PbV33tEG3qfkhhBlydSvAKxfLZSfB4lsJHg=
github.com/onflow/flow-core-contracts/lib/go/templates v1.3.0 h1:aMFJdB2CW+Dzm+AJ5QN6J1yWh+a0l2RxHN2/TtLaXUo=
github.com/onflow/flow-core-contracts/lib/go/templates v1.3.0/go.mod h1:NgbMOYnMh0GN48VsNKZuiwK7uyk38Wyo8jN9+C9QE30=
github.com/onflow/flow-emulator v1.0.0-preview.35 h1:lvj93PUiQo40RC4tfMiCizoR8Dx7MYqYZ4pw+rVe0v4=
github.com/onflow/flow-emulator v1.0.0-preview.35/go.mod h1:gST95yjIEURRhyufePZfJoH5HMiwTDcnGcJ7LD7/E84=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.1 h1:q9tXLIALwQ76bO4bmSrhtTkyc2cZF4/gH11ix9E3F5k=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.1/go.mod h1:u/mkP/B+PbV33tEG3qfkhhBlydSvAKxfLZSfB4lsJHg=
github.com/onflow/flow-core-contracts/lib/go/templates v1.3.1 h1:FfhMBAb78p6VAWkJ+iqdKLErGQVQgxk5w6DP5ZruWX8=
github.com/onflow/flow-core-contracts/lib/go/templates v1.3.1/go.mod h1:NgbMOYnMh0GN48VsNKZuiwK7uyk38Wyo8jN9+C9QE30=
github.com/onflow/flow-emulator v1.0.0-preview.36 h1:XCBWo6XNcnejxw17Qz8lmHW1fzwzApbrm4nxWp09yt4=
github.com/onflow/flow-emulator v1.0.0-preview.36/go.mod h1:ngGgic4WYQzlW7esXgGQOpm1Berfar6q+z3qbDQ8ay8=
github.com/onflow/flow-ft/lib/go/contracts v1.0.0 h1:mToacZ5NWqtlWwk/7RgIl/jeKB/Sy/tIXdw90yKHcV0=
github.com/onflow/flow-ft/lib/go/contracts v1.0.0/go.mod h1:PwsL8fC81cjnUnTfmyL/HOIyHnyaw/JA474Wfj2tl6A=
github.com/onflow/flow-ft/lib/go/templates v1.0.0 h1:6cMS/lUJJ17HjKBfMO/eh0GGvnpElPgBXx7h5aoWJhs=
github.com/onflow/flow-ft/lib/go/templates v1.0.0/go.mod h1:uQ8XFqmMK2jxyBSVrmyuwdWjTEb+6zGjRYotfDJ5pAE=
github.com/onflow/flow-go v0.36.2-0.20240717214129-9ea6faeee3e7 h1:ZlqdL88tBWCGqooqaFPgspwuwCPb+e2xE5imLEEYfTA=
github.com/onflow/flow-go v0.36.2-0.20240717214129-9ea6faeee3e7/go.mod h1:6M6tijXZLxQkzsF3IVIIuRk2lzHvMg2mVnirtLaMW18=
github.com/onflow/flow-go v0.36.4-0.20240724205438-14f9fddeda2b h1:hgna3jsW/w9WcY7I5P19pU9882iCm2BM2nJMY3SDyRE=
github.com/onflow/flow-go v0.36.4-0.20240724205438-14f9fddeda2b/go.mod h1:OGWZcM13nXoqBF3nyv5en/NVtBN9e5zJe4eLV1dzXSE=
github.com/onflow/flow-go-sdk v1.0.0-M1/go.mod h1:TDW0MNuCs4SvqYRUzkbRnRmHQL1h4X8wURsCw9P9beo=
github.com/onflow/flow-go-sdk v1.0.0-preview.41 h1:pOUAIQdlWuc90tQzYixCXkqmnoorDgsFxTu2J1wlhHA=
github.com/onflow/flow-go-sdk v1.0.0-preview.41/go.mod h1:FyJiLluqK+sNo+ky9VU6HSwVkvhv5/fKH1sIKI1yrrI=
github.com/onflow/flow-go-sdk v1.0.0-preview.42 h1:XcHWRQfkJ5A24sNqnmo3DocHdf5ulDJLie9/yh5c1Y4=
github.com/onflow/flow-go-sdk v1.0.0-preview.42/go.mod h1:4/ELH5ooEdZ+9tZfoiTIkkB4B6wVgy4HbMjS/9w/67Q=
github.com/onflow/flow-nft/lib/go/contracts v1.2.1 h1:woAAS5z651sDpi7ihAHll8NvRS9uFXIXkL6xR+bKFZY=
github.com/onflow/flow-nft/lib/go/contracts v1.2.1/go.mod h1:2gpbza+uzs1k7x31hkpBPlggIRkI53Suo0n2AyA2HcE=
github.com/onflow/flow-nft/lib/go/templates v1.2.0 h1:JSQyh9rg0RC+D1930BiRXN8lrtMs+ubVMK6aQPon6Yc=
github.com/onflow/flow-nft/lib/go/templates v1.2.0/go.mod h1:p+2hRvtjLUR3MW1NsoJe5Gqgr2eeH49QB6+s6ze00w0=
github.com/onflow/flow/protobuf/go/flow v0.3.2-0.20231121210617-52ee94b830c2/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk=
github.com/onflow/flow/protobuf/go/flow v0.4.5 h1:6o+pgYGqwXdEhqSJxu2BdnDXkOQVOkfGAb6IiXB+NPM=
github.com/onflow/flow/protobuf/go/flow v0.4.5/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk=
github.com/onflow/flowkit/v2 v2.0.0-stable-cadence-alpha.26 h1:aFatTOyd33dqCj9GSkMNNVtpHH5nEXsyNr1eA+SHCCA=
github.com/onflow/flowkit/v2 v2.0.0-stable-cadence-alpha.26/go.mod h1:2FxUTSEATtab10G0KxcKiLTAlrw8OqyTWa4OmgOnqoM=
github.com/onflow/flowkit/v2 v2.0.0-stable-cadence-alpha.29 h1:9t+/P9wRhmSshJOmLqxkrGqVhyFw3/QfIfmhQillJrs=
github.com/onflow/flowkit/v2 v2.0.0-stable-cadence-alpha.29/go.mod h1:yoH9656uDqoh+PQJCsxPeSrqqWWPkmkaqabZZWfbnko=
github.com/onflow/go-ethereum v1.14.7 h1:gg3awYqI02e3AypRdpJKEvNTJ6kz/OhAqRti0h54Wlc=
github.com/onflow/go-ethereum v1.14.7/go.mod h1:zV14QLrXyYu5ucvcwHUA0r6UaqveqbXaehAVQJlSW+I=
github.com/onflow/sdks v0.5.1-0.20230912225508-b35402f12bba/go.mod h1:F0dj0EyHC55kknLkeD10js4mo14yTdMotnWMslPirrU=
Expand Down
50 changes: 50 additions & 0 deletions state.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ type OverflowClient interface {

// use this method to transform a flow transactionResult and transaction into a overflow transaction
CreateOverflowTransaction(blockId string, transactionResult flow.TransactionResult, transaction flow.Transaction, txIndex int) (*OverflowTransaction, error)

CreateTestAccounts(ctx context.Context, num int, flowTokens float64) (map[string]*accounts.Account, error)
}

var _ OverflowClient = (*OverflowState)(nil)
Expand Down Expand Up @@ -892,3 +894,51 @@ func (o *OverflowState) GetCoverageReport() *runtime.CoverageReport {
func (o *OverflowState) RollbackToBlockHeight(height uint64) error {
return o.EmulatorGatway.RollbackToBlockHeight(height)
}

// this methods create test accounts that can be used in WithManualSigner, they are not in flow json
func (o *OverflowState) CreateTestAccounts(ctx context.Context, num int, flowTokens float64) (map[string]*accounts.Account, error) {
account, err := o.AccountE("account")
if err != nil {
return nil, err
}

pk, err := account.Key.PrivateKey()
if err != nil {
return nil, err
}
pki := *pk

accountKey := accounts.NewHexKeyFromPrivateKey(0, account.Key.HashAlgo(), pki)
users := map[string]*accounts.Account{}

keys := []accounts.PublicKey{{
Public: pki.PublicKey(),
Weight: 1000,
SigAlgo: account.Key.SigAlgo(),
HashAlgo: account.Key.HashAlgo(),
}}

for i := 0; i < num; i++ {
userAccount, _, err := o.Flowkit.CreateAccount(ctx, account, keys)
if err != nil {
return nil, err
}

address := userAccount.Address.Hex()
if flowTokens > 0.0 {
result := o.MintFlowTokens(address, flowTokens)
if result.Error != nil {
return nil, result.Error
}
}

a := &accounts.Account{
Name: fmt.Sprintf("user-%d", i),
Address: userAccount.Address,
Key: accountKey,
}

users[userAccount.Address.Hex()] = a
}
return users, nil
}
2 changes: 1 addition & 1 deletion transaction_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func TestTransactionIntegration(t *testing.T) {
assert.Equal(t, 1, len(result.GetEventsWithName("FungibleToken.Deposited")))

report := o.GetCoverageReport()
assert.Equal(t, "18.7%", report.Summary().Coverage)
assert.Equal(t, "19.4%", report.Summary().Coverage)
})

t.Run("Mint tokens assert events with built in assertion", func(t *testing.T) {
Expand Down