mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-05 23:55:11 +00:00
core: refactor native call
1. `System.Contract.CallNative` expects version on stack. 2. Actual method is determined based on current instruction pointer. 3. Native hashes don't longer depend on NEF checksum.
This commit is contained in:
parent
f264996f74
commit
f9f1fe03b2
33 changed files with 128 additions and 102 deletions
|
@ -25,6 +25,7 @@ import (
|
|||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
||||
"github.com/nspcc-dev/neo-go/pkg/io"
|
||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag"
|
||||
|
@ -591,7 +592,7 @@ func TestVerifyTx(t *testing.T) {
|
|||
w := io.NewBufBinWriter()
|
||||
emit.Opcodes(w.BinWriter, opcode.ABORT)
|
||||
emit.Bytes(w.BinWriter, util.Uint160{}.BytesBE())
|
||||
emit.Int(w.BinWriter, int64(orc.NEF.Checksum))
|
||||
emit.Int(w.BinWriter, 0)
|
||||
emit.String(w.BinWriter, orc.Manifest.Name)
|
||||
tx.Scripts[len(tx.Scripts)-1].VerificationScript = w.Bytes()
|
||||
err := bc.VerifyTx(tx)
|
||||
|
@ -1005,7 +1006,7 @@ func TestVerifyTx(t *testing.T) {
|
|||
transaction.NotaryServiceFeePerKey + // fee for Notary attribute
|
||||
fee.Opcode(bc.GetBaseExecFee(), // Notary verification script
|
||||
opcode.PUSHDATA1, opcode.RET, // invocation script
|
||||
opcode.PUSHINT8, opcode.SYSCALL, opcode.RET) + // Neo.Native.Call
|
||||
opcode.PUSH0, opcode.SYSCALL, opcode.RET) + // Neo.Native.Call
|
||||
native.NotaryVerificationPrice // Notary witness verification price
|
||||
tx.Scripts = []transaction.Witness{
|
||||
{
|
||||
|
@ -1204,7 +1205,8 @@ func TestIsTxStillRelevant(t *testing.T) {
|
|||
"github.com/nspcc-dev/neo-go/pkg/interop/util"
|
||||
)
|
||||
func Verify() bool {
|
||||
currentHeight := contract.Call(util.FromAddress("NV5WuMGkwhQexQ4afTwuRojMeWwfWrEAdv"), "currentIndex", contract.ReadStates)
|
||||
addr := util.FromAddress("`+address.Uint160ToString(bc.contracts.Ledger.Hash)+`")
|
||||
currentHeight := contract.Call(addr, "currentIndex", contract.ReadStates)
|
||||
return currentHeight.(int) < %d
|
||||
}`, bc.BlockHeight()+2) // deploy + next block
|
||||
txDeploy, h, err := testchain.NewDeployTx(bc, "TestVerify", neoOwner, strings.NewReader(src))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue