core: fix VerifyTX test

HighPriority attribute was lost during intermediate code changes.
This commit is contained in:
Evgenii Stratonikov 2020-08-27 18:17:15 +03:00
parent dce456f77f
commit 1788cf02a1

View file

@ -17,7 +17,6 @@ import (
"github.com/nspcc-dev/neo-go/pkg/crypto/hash" "github.com/nspcc-dev/neo-go/pkg/crypto/hash"
"github.com/nspcc-dev/neo-go/pkg/internal/testchain" "github.com/nspcc-dev/neo-go/pkg/internal/testchain"
"github.com/nspcc-dev/neo-go/pkg/io" "github.com/nspcc-dev/neo-go/pkg/io"
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
"github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger" "github.com/nspcc-dev/neo-go/pkg/smartcontract/trigger"
"github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neo-go/pkg/util"
"github.com/nspcc-dev/neo-go/pkg/vm" "github.com/nspcc-dev/neo-go/pkg/vm"
@ -234,6 +233,9 @@ func TestVerifyTx(t *testing.T) {
emit.Opcode(w.BinWriter, opcode.ASSERT) emit.Opcode(w.BinWriter, opcode.ASSERT)
} }
} }
emit.AppCallWithOperationAndArgs(w.BinWriter, gasHash, "transfer",
neoOwner, testchain.CommitteeScriptHash(), int64(1_000_000_000))
emit.Opcode(w.BinWriter, opcode.ASSERT)
require.NoError(t, w.Err) require.NoError(t, w.Err)
txMove := bc.newTestTx(neoOwner, w.Bytes()) txMove := bc.newTestTx(neoOwner, w.Bytes())
@ -355,13 +357,13 @@ func TestVerifyTx(t *testing.T) {
}) })
t.Run("ValidHighPriority", func(t *testing.T) { t.Run("ValidHighPriority", func(t *testing.T) {
tx := bc.newTestTx(h, testScript) tx := bc.newTestTx(h, testScript)
tx.Attributes = append(tx.Attributes, transaction.Attribute{Type: transaction.HighPriority})
tx.NetworkFee += 4_000_000 // multisig check tx.NetworkFee += 4_000_000 // multisig check
tx.Signers = []transaction.Signer{{ tx.Signers = []transaction.Signer{{
Account: testchain.MultisigScriptHash(), Account: testchain.CommitteeScriptHash(),
Scopes: transaction.FeeOnly, Scopes: transaction.FeeOnly,
}} }}
validators := bc.GetStandByValidators() rawScript := testchain.CommitteeVerificationScript()
rawScript, err := smartcontract.CreateMajorityMultiSigRedeemScript(validators)
require.NoError(t, err) require.NoError(t, err)
size := io.GetVarSize(tx) size := io.GetVarSize(tx)
netFee, sizeDelta := CalculateNetworkFee(rawScript) netFee, sizeDelta := CalculateNetworkFee(rawScript)
@ -369,7 +371,7 @@ func TestVerifyTx(t *testing.T) {
tx.NetworkFee += int64(size+sizeDelta) * bc.FeePerByte() tx.NetworkFee += int64(size+sizeDelta) * bc.FeePerByte()
data := tx.GetSignedPart() data := tx.GetSignedPart()
tx.Scripts = []transaction.Witness{{ tx.Scripts = []transaction.Witness{{
InvocationScript: testchain.Sign(data), InvocationScript: testchain.SignCommittee(data),
VerificationScript: rawScript, VerificationScript: rawScript,
}} }}
require.NoError(t, bc.VerifyTx(tx)) require.NoError(t, bc.VerifyTx(tx))