Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
Signed-off-by: Ekaterina Pavlova <[email protected]>
  • Loading branch information
AliceInHunterland committed Feb 28, 2024
1 parent 6a560b9 commit 03ad7f4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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$

29 changes: 26 additions & 3 deletions cli/nep_test/nep17_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package nep_test

import (
"fmt"
"io"
"math/big"
"path/filepath"
Expand All @@ -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"
)
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 03ad7f4

Please sign in to comment.