Skip to content

Commit

Permalink
test: fix GA
Browse files Browse the repository at this point in the history
  • Loading branch information
davidyuk committed Jun 8, 2021
1 parent 25e16bf commit 951b02e
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions integration_test/ga_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (

"github.com/aeternity/aepp-sdk-go/v8/account"
"github.com/aeternity/aepp-sdk-go/v8/aeternity"
"github.com/aeternity/aepp-sdk-go/v8/binary"
"github.com/aeternity/aepp-sdk-go/v8/config"
"github.com/aeternity/aepp-sdk-go/v8/models"
"github.com/aeternity/aepp-sdk-go/v8/naet"
"github.com/aeternity/aepp-sdk-go/v8/transactions"
"github.com/aeternity/aepp-sdk-go/v8/utils"
Expand Down Expand Up @@ -69,15 +69,15 @@ func TestGeneralizedAccounts(t *testing.T) {
}

// GAAttachTx
// Create a Contract{} struct from the compiled bytecode to get its authfunc hash
auth, err := models.NewContractFromString(authBytecode)
authFuncHash, err := binary.Blake2bHash([]byte("authorize"))
if err != nil {
t.Fatal(err)
}
gaTx, err := transactions.NewGAAttachTx(testAccount.Address, authBytecode, auth.TypeInfo[0].FuncHash, config.Client.Contracts.VMVersion, config.Client.Contracts.ABIVersion, config.Client.Contracts.GasLimit, config.Client.GasPrice, authInitCalldata, ctx.TTLNoncer())
gaTx, err := transactions.NewGAAttachTx(testAccount.Address, authBytecode, authFuncHash, config.Client.Contracts.VMVersion, config.Client.Contracts.ABIVersion, config.Client.Contracts.GasLimit, config.Client.GasPrice, authInitCalldata, ctx.TTLNoncer())
if err != nil {
t.Fatal(err)
}
ctx.SigningAccount = testAccount
_, err = ctx.SignBroadcastWait(gaTx, config.Client.WaitBlocks)
if err != nil {
t.Fatal(err)
Expand All @@ -98,15 +98,17 @@ func TestGeneralizedAccounts(t *testing.T) {
// GAMetaTx
// spendTx will be wrapped in a SignedTx with 0 signatures before being
// included in GAMetaTx. The constructor NewGAMetaTx() does this for you.
// authData is authorize(3)
authData := "cb_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACBGtXufEG2HuMYcRcNwsGAeqymslunKf692bHnvwI5K6wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAU3aKBNm"
authData, err := compiler.EncodeCalldata(authorizeSource, "authorize", []string{"3"}, config.Compiler.Backend)
if err != nil {
t.Fatal(err)
}
metaTxTTLNoncer := func(accountID string, offset uint64) (ttl, height, nonce uint64, err error) {
return 0, 0, 0, nil
}
spendTx, err := transactions.NewSpendTx(testAccount.Address, bob.Address, big.NewInt(5000), []byte{}, metaTxTTLNoncer)
gaMetaTx, err := transactions.NewGAMetaTx(testAccount.Address, authData, config.Client.Contracts.ABIVersion, config.Client.GasPrice, config.Client.GasPrice, spendTx, ctx.TTLNoncer())
gaMetaTx, err := transactions.NewGAMetaTx(testAccount.Address, authData, config.Client.Contracts.ABIVersion, big.NewInt(50000), config.Client.GasPrice, spendTx, ctx.TTLNoncer())

gaMetaTxFinal, hash, _, err := transactions.SignHashTx(testAccount, gaMetaTx, config.Node.NetworkID)
gaMetaTxFinal, hash, _, err := transactions.SignHashTx(alice, gaMetaTx, config.Node.NetworkID)
if err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit 951b02e

Please sign in to comment.