core/tests: extend native contract test

Check if native contract's method price is taken into account.
This commit is contained in:
Evgenii Stratonikov 2020-06-18 22:43:04 +03:00
parent 5354352d63
commit e7d8bb92f6

View file

@ -107,7 +107,14 @@ func TestNativeContract_Invoke(t *testing.T) {
tx.ValidUntilBlock = validUntil tx.ValidUntilBlock = validUntil
require.NoError(t, addSender(tx)) require.NoError(t, addSender(tx))
require.NoError(t, signTx(chain, tx)) require.NoError(t, signTx(chain, tx))
b := chain.newBlock(tx)
// Enough for Call and other opcodes, but not enough for "sum" call.
tx2 := transaction.New(chain.GetConfig().Magic, script, testSumPrice*2)
tx2.ValidUntilBlock = chain.blockHeight + 1
require.NoError(t, addSender(tx2))
require.NoError(t, signTx(chain, tx2))
b := chain.newBlock(tx, tx2)
require.NoError(t, chain.AddBlock(b)) require.NoError(t, chain.AddBlock(b))
res, err := chain.GetAppExecResult(tx.Hash()) res, err := chain.GetAppExecResult(tx.Hash())
@ -117,6 +124,10 @@ func TestNativeContract_Invoke(t *testing.T) {
require.Equal(t, smartcontract.IntegerType, res.Stack[0].Type) require.Equal(t, smartcontract.IntegerType, res.Stack[0].Type)
require.EqualValues(t, 42, res.Stack[0].Value) require.EqualValues(t, 42, res.Stack[0].Value)
res, err = chain.GetAppExecResult(tx2.Hash())
require.NoError(t, err)
require.Equal(t, "FAULT", res.VMState)
require.NoError(t, chain.persist()) require.NoError(t, chain.persist())
select { select {
case index := <-tn.blocks: case index := <-tn.blocks: