Merge pull request #803 from nspcc-dev/feature/appcall

emit: implement AppCallWithOperationAndArgs
This commit is contained in:
Roman Khimov 2020-03-27 13:30:48 +03:00 committed by GitHub
commit c738975b7b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 64 additions and 24 deletions

View file

@ -317,12 +317,7 @@ func TestCreateBasicChain(t *testing.T) {
// Now invoke this contract.
script = io.NewBufBinWriter()
emit.String(script.BinWriter, "testvalue")
emit.String(script.BinWriter, "testkey")
emit.Int(script.BinWriter, 2)
emit.Opcode(script.BinWriter, opcode.PACK)
emit.String(script.BinWriter, "Put")
emit.AppCall(script.BinWriter, hash.Hash160(avm), false)
emit.AppCallWithOperationAndArgs(script.BinWriter, hash.Hash160(avm), "Put", "testkey", "testvalue")
txInv := transaction.NewInvocationTX(script.Bytes(), 0)
b = bc.newBlock(newMinerTX(), txInv)
@ -354,10 +349,7 @@ func TestCreateBasicChain(t *testing.T) {
sh := hash.Hash160(avm)
w := io.NewBufBinWriter()
emit.Int(w.BinWriter, 0)
emit.Opcode(w.BinWriter, opcode.NEWARRAY)
emit.String(w.BinWriter, "init")
emit.AppCall(w.BinWriter, sh, true)
emit.AppCallWithOperationAndArgs(w.BinWriter, sh, "init")
initTx := transaction.NewInvocationTX(w.Bytes(), 0)
transferTx := newNEP5Transfer(sh, sh, priv0.GetScriptHash(), 1000)
@ -403,13 +395,7 @@ func TestCreateBasicChain(t *testing.T) {
func newNEP5Transfer(sc, from, to util.Uint160, amount int64) *transaction.Transaction {
w := io.NewBufBinWriter()
emit.Int(w.BinWriter, amount)
emit.Bytes(w.BinWriter, to.BytesBE())
emit.Bytes(w.BinWriter, from.BytesBE())
emit.Int(w.BinWriter, 3)
emit.Opcode(w.BinWriter, opcode.PACK)
emit.String(w.BinWriter, "transfer")
emit.AppCall(w.BinWriter, sc, false)
emit.AppCallWithOperationAndArgs(w.BinWriter, sc, "transfer", from, to, amount)
emit.Opcode(w.BinWriter, opcode.THROWIFNOT)
script := w.Bytes()