core: add Notary module test

This commit is contained in:
Anna Shaleva 2021-01-26 19:37:19 +03:00 committed by AnnaShaleva
parent 4ad9c7929b
commit df26ca1c7f
7 changed files with 1168 additions and 1 deletions

View file

@ -15,6 +15,7 @@ import (
"github.com/nspcc-dev/neo-go/internal/testserdes"
"github.com/nspcc-dev/neo-go/pkg/config"
"github.com/nspcc-dev/neo-go/pkg/core/block"
"github.com/nspcc-dev/neo-go/pkg/core/blockchainer"
"github.com/nspcc-dev/neo-go/pkg/core/chaindump"
"github.com/nspcc-dev/neo-go/pkg/core/fee"
"github.com/nspcc-dev/neo-go/pkg/core/native"
@ -391,6 +392,9 @@ func newNEP17Transfer(sc, from, to util.Uint160, amount int64, additionalArgs ..
w := io.NewBufBinWriter()
emit.AppCall(w.BinWriter, sc, "transfer", callflag.All, from, to, amount, additionalArgs)
emit.Opcodes(w.BinWriter, opcode.ASSERT)
if w.Err != nil {
panic(fmt.Errorf("failed to create nep17 transfer transaction: %w", w.Err))
}
script := w.Bytes()
return transaction.New(testchain.Network(), script, 11000000)
@ -564,3 +568,19 @@ func checkBalanceOf(t *testing.T, chain *Blockchain, addr util.Uint160, expected
balance := chain.GetNEP17Balances(addr).Trackers[chain.contracts.GAS.ContractID]
require.Equal(t, int64(expected), balance.Balance.Int64())
}
type NotaryFeerStub struct {
bc blockchainer.Blockchainer
}
func (f NotaryFeerStub) FeePerByte() int64 { return f.bc.FeePerByte() }
func (f NotaryFeerStub) GetUtilityTokenBalance(acc util.Uint160) *big.Int {
return f.bc.GetNotaryBalance(acc)
}
func (f NotaryFeerStub) BlockHeight() uint32 { return f.bc.BlockHeight() }
func (f NotaryFeerStub) P2PSigExtensionsEnabled() bool { return f.bc.P2PSigExtensionsEnabled() }
func NewNotaryFeerStub(bc blockchainer.Blockchainer) NotaryFeerStub {
return NotaryFeerStub{
bc: bc,
}
}