From 03ad7f4067215bb8572927a43a513199d8f2d02d Mon Sep 17 00:00:00 2001 From: Ekaterina Pavlova Date: Wed, 28 Feb 2024 14:40:15 +0300 Subject: [PATCH] test Signed-off-by: Ekaterina Pavlova --- .github/workflows/tests.yml | 3 ++- cli/nep_test/nep17_test.go | 29 ++++++++++++++++++++++++++--- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b475320e7a..600885168e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -150,4 +150,5 @@ jobs: cache: true - name: Run tests - run: go test -v -race ./... + run: go test -v -race ./cli/nep_test -run ^TestNEP17Balance$ + diff --git a/cli/nep_test/nep17_test.go b/cli/nep_test/nep17_test.go index f933e0559d..1b58158e07 100644 --- a/cli/nep_test/nep17_test.go +++ b/cli/nep_test/nep17_test.go @@ -1,6 +1,7 @@ package nep_test import ( + "fmt" "io" "math/big" "path/filepath" @@ -13,6 +14,7 @@ import ( "github.com/nspcc-dev/neo-go/pkg/encoding/address" "github.com/nspcc-dev/neo-go/pkg/encoding/fixedn" "github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest" + "github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/wallet" "github.com/stretchr/testify/require" ) @@ -64,14 +66,35 @@ func TestNEP17Balance(t *testing.T) { e.CheckNextLine(t, "^\\s*$") }) t.Run("all accounts", func(t *testing.T) { + getUtilityTokenBalance := func(acc util.Uint160) (*big.Int, uint32) { + gasHash, err := e.Chain.GetNativeContractScriptHash(nativenames.Gas) + require.NoError(t, err) + + gasState := e.Chain.GetContractState(gasHash) + require.NotNil(t, gasState) + + lub, err := e.Chain.GetTokenLastUpdated(acc) + require.NoError(t, err) + balance := e.Chain.GetUtilityTokenBalance(acc) + fmt.Println("getUtilityTokenBalance") + fmt.Println(gasState.ID) + fmt.Println(lub[gasState.ID]) + fmt.Println(balance) + return balance, lub[gasState.ID] + } e.Run(t, cmdbase...) addr1, err := address.StringToUint160("Nhfg3TbpwogLvDGVvAvqyThbsHgoSUKwtn") require.NoError(t, err) e.CheckNextLine(t, "^Account "+address.Uint160ToString(addr1)) e.CheckNextLine(t, "^\\s*GAS:\\s+GasToken \\("+e.Chain.UtilityTokenHash().StringLE()+"\\)") - balance := e.Chain.GetUtilityTokenBalance(addr1) - e.CheckNextLine(t, "^\\s*Amount\\s*:\\s*"+fixedn.Fixed8(balance.Int64()).String()+"$") - e.CheckNextLine(t, "^\\s*Updated:") + balance, index := getUtilityTokenBalance(addr1) + b := e.GetNextLine(t) + fmt.Println(b, fixedn.Fixed8(balance.Int64()).String() == b) + //e.CheckNextLine(t, "^\\s*Amount\\s*:\\s*"+fixedn.Fixed8(balance.Int64()).String()+"$") + update := e.GetNextLine(t) + fmt.Println(strconv.FormatUint(uint64(index), 10)) + fmt.Println(update) + //e.CheckNextLine(t, "^\\s*Updated\\s*:\\s*"+strconv.FormatUint(uint64(index), 10)) e.CheckNextLine(t, "^\\s*$") addr2, err := address.StringToUint160("NVTiAjNgagDkTr5HTzDmQP9kPwPHN5BgVq")