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 all commits
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
6 changes: 3 additions & 3 deletions doc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func ExampleOverflowState_Tx() {
//🧑 Created account: emulator-first with address: 179b6b1cb6755e31 with flow: 10.00
//🧑 Created account: emulator-second with address: f3fcd2c1a78f5eee with flow: 10.00
//📜 deploy contracts Debug
//👌 Tx:arguments fee:0.00001000 gas:18
//👌 Tx:arguments fee:0.00001000 gas:21
//
}

Expand All @@ -55,7 +55,7 @@ func ExampleOverflowState_Tx_inline() {
//🧑 Created account: emulator-first with address: 179b6b1cb6755e31 with flow: 10.00
//🧑 Created account: emulator-second with address: f3fcd2c1a78f5eee with flow: 10.00
//📜 deploy contracts Debug
//👌 Tx: fee:0.00001000 gas:27
//👌 Tx: fee:0.00001000 gas:35
//=== Events ===
//A.f8d6e0586b0a20c7.Debug.Log
// msg -> overflow ftw!
Expand All @@ -81,7 +81,7 @@ func ExampleOverflowState_Tx_multisign() {
//🧑 Created account: emulator-first with address: 179b6b1cb6755e31 with flow: 10.00
//🧑 Created account: emulator-second with address: f3fcd2c1a78f5eee with flow: 10.00
//📜 deploy contracts Debug
//👌 Tx: fee:0.00001000 gas:29
//👌 Tx: fee:0.00001000 gas:36
//=== Events ===
//A.f8d6e0586b0a20c7.Debug.Log
// msg -> acct:0xf3fcd2c1a78f5eee
Expand Down
16 changes: 8 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ toolchain go1.22.3

require (
github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de
github.com/bjartek/underflow v1.7.0
github.com/bjartek/underflow v1.8.0
github.com/enescakir/emoji v1.0.0
github.com/fatih/color v1.16.0
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.39
github.com/onflow/cadence v1.0.0-preview.48
github.com/onflow/flixkit-go v1.2.1-cadence-v1-preview.18
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.27
github.com/onflow/flow-emulator v1.0.0-preview.39
github.com/onflow/flow-go v0.37.1
github.com/onflow/flow-go-sdk v1.0.0-preview.50
github.com/onflow/flowkit/v2 v2.0.0-stable-cadence-alpha.30
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 @@ -161,7 +161,7 @@ require (
github.com/multiformats/go-varint v0.0.7 // indirect
github.com/nightlyone/lockfile v1.0.0 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/onflow/atree v0.7.0-rc.2 // indirect
github.com/onflow/atree v0.8.0-rc.5 // indirect
github.com/onflow/crypto v0.25.1 // 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
Expand Down Expand Up @@ -243,7 +243,7 @@ require (
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
lukechampine.com/blake3 v1.2.1 // indirect
lukechampine.com/blake3 v1.3.0 // indirect
modernc.org/libc v1.37.6 // indirect
modernc.org/mathutil v1.6.0 // indirect
modernc.org/memory v1.7.2 // indirect
Expand Down
31 changes: 16 additions & 15 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1074,8 +1074,8 @@ 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.7.0 h1:9B3m+IpAX5j9f5n8FlkxnwsSgvsnkdhzYlusNdQYSHY=
github.com/bjartek/underflow v1.7.0/go.mod h1:3dujqcYAOma8r05PZW9qBoHNnHpcb4fWRbNX0181YN4=
github.com/bjartek/underflow v1.8.0 h1:l4Us9RoTgAaM2TZVc7GHSGQizaYQzTNCD4T39KKhP9U=
github.com/bjartek/underflow v1.8.0/go.mod h1:dru+wx1KRuaVV3gHm30BxibT0gRwZkuh9E/i+T26KIc=
github.com/bmizerany/pat v0.0.0-20170815010413-6226ea591a40/go.mod h1:8rLXio+WjiTceGBHIoTvn60HIbs7Hm7bcHjyrSqYB9c=
github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps=
github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
Expand Down Expand Up @@ -1965,11 +1965,11 @@ github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
github.com/onflow/atree v0.6.1-0.20230711151834-86040b30171f/go.mod h1:xvP61FoOs95K7IYdIYRnNcYQGf4nbF/uuJ0tHf4DRuM=
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/atree v0.8.0-rc.5 h1:1sU+c6UfDzq/EjM8nTw4EI8GvEMarcxkWkJKy6piFSY=
github.com/onflow/atree v0.8.0-rc.5/go.mod h1:yccR+LR7xc1Jdic0mrjocbHvUD7lnVvg8/Ct1AA5zBo=
github.com/onflow/cadence v1.0.0-M3/go.mod h1:odXGZZ/wGNA5mwT8bC9v8u8EXACHllB2ABSZK65TGL8=
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/cadence v1.0.0-preview.48 h1:WkgU0z6H/oRe44kLL6OO+wkGeKULWChoCT8i7sgiWdg=
github.com/onflow/cadence v1.0.0-preview.48/go.mod h1:BCoenp1TYp+SmG7FGWStjehvvzcvNQ3xvpK5rkthq3Y=
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=
Expand All @@ -1979,26 +1979,26 @@ github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.1 h1:q9tXLIALwQ76bO4
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-emulator v1.0.0-preview.39 h1:5z/jKUrU3YB/Lqvr1bNTDW2BGIcCJocLdw06Rk87r+U=
github.com/onflow/flow-emulator v1.0.0-preview.39/go.mod h1:0mXSq9eSwkAmGgvn/8aCBNgXiJM6MHKETFgPSk6f9NA=
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.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 v0.37.1 h1:DHvadojDigTOjLBLrwwKyyWXVRawmlefAk/DNVbK8cQ=
github.com/onflow/flow-go v0.37.1/go.mod h1:hLFem+cwkq6650p4+0DUp36GH2QEuuFDCDUzDg0QZNE=
github.com/onflow/flow-go-sdk v1.0.0-M1/go.mod h1:TDW0MNuCs4SvqYRUzkbRnRmHQL1h4X8wURsCw9P9beo=
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-go-sdk v1.0.0-preview.50 h1:j5HotrV/ieo5JckmMxR2dMxO3x1j7YO8SP2EuGMEwRQ=
github.com/onflow/flow-go-sdk v1.0.0-preview.50/go.mod h1:Ykk4PS7fgWuc6BB073tdzHu/VtzOd0CVNIoDjaqFHLg=
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.27 h1:3OhMqkXAgi4n8caM86rp+PqpvYufrcreuXw5k7PQIGs=
github.com/onflow/flowkit/v2 v2.0.0-stable-cadence-alpha.27/go.mod h1:yoH9656uDqoh+PQJCsxPeSrqqWWPkmkaqabZZWfbnko=
github.com/onflow/flowkit/v2 v2.0.0-stable-cadence-alpha.30 h1:d9ghYPewpcouo6uIbcxBTsfuzDKSYITtCdaxVeDQ/bw=
github.com/onflow/flowkit/v2 v2.0.0-stable-cadence-alpha.30/go.mod h1:6GwkwNKorzFMqXxOaFHk2SypMe/kajEoo8UnoJDWD2U=
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 Expand Up @@ -3293,8 +3293,9 @@ honnef.co/go/tools v0.1.3/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las=
launchpad.net/gocheck v0.0.0-20140225173054-000000000087 h1:Izowp2XBH6Ya6rv+hqbceQyw/gSGoXfH/UPoTGduL54=
launchpad.net/gocheck v0.0.0-20140225173054-000000000087/go.mod h1:hj7XX3B/0A+80Vse0e+BUHsHMTEhd0O4cpUHr/e/BUM=
lukechampine.com/blake3 v1.1.7/go.mod h1:tkKEOtDkNtklkXtLNEOGNq5tcV90tJiA1vAA12R78LA=
lukechampine.com/blake3 v1.2.1 h1:YuqqRuaqsGV71BV/nm9xlI0MKUv4QC54jQnBChWbGnI=
lukechampine.com/blake3 v1.2.1/go.mod h1:0OFRp7fBtAylGVCO40o87sbupkyIGgbpv1+M1k1LM6k=
lukechampine.com/blake3 v1.3.0 h1:sJ3XhFINmHSrYCgl958hscfIa3bw8x4DqMP3u1YvoYE=
lukechampine.com/blake3 v1.3.0/go.mod h1:0OFRp7fBtAylGVCO40o87sbupkyIGgbpv1+M1k1LM6k=
lukechampine.com/uint128 v1.1.1/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk=
lukechampine.com/uint128 v1.2.0/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk=
modernc.org/cc/v3 v3.36.0/go.mod h1:NFUHyPn4ekoC/JHeZFfZurN6ixxawE1BnVonP/oahEI=
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 @@ -411,7 +411,7 @@ func TestFillUpSpace(t *testing.T) {
o, err := OverflowTesting(WithFlowForNewUsers(0.001))
assert.NoError(t, err)
result := o.GetFreeCapacity("first")
assert.Equal(t, 198857, result)
assert.Equal(t, 198993, result)
o.FillUpStorage("first")
assert.NoError(t, o.Error)

Expand Down
Loading