mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-23 13:41:37 +00:00
transaction: remove type field, set Version to 0
Two changes being done here, because they require a lot of updates to tests. Now we're back into version 0 and we only have one type of transaction. It also removes GetType and GetScript interops, both are obsolete in Neo 3.
This commit is contained in:
parent
2ef9ec0756
commit
21efccd300
33 changed files with 216 additions and 449 deletions
|
@ -77,7 +77,7 @@ func getTX(t *testing.B, wif *keys.WIF) *transaction.Transaction {
|
|||
fromAddressHash, err := address.StringToUint160(fromAddress)
|
||||
require.NoError(t, err)
|
||||
|
||||
tx := transaction.NewInvocationTX([]byte{0x51}, 1)
|
||||
tx := transaction.New([]byte{0x51}, 1)
|
||||
tx.Version = 0
|
||||
tx.Sender = fromAddressHash
|
||||
tx.Attributes = append(tx.Attributes,
|
||||
|
|
|
@ -70,8 +70,6 @@ var syscalls = map[string]map[string]string{
|
|||
"GetInputs": "Neo.Transaction.GetInputs",
|
||||
"GetOutputs": "Neo.Transaction.GetOutputs",
|
||||
"GetReferences": "Neo.Transaction.GetReferences",
|
||||
"GetScript": "Neo.InvocationTransaction.GetScript",
|
||||
"GetType": "Neo.Transaction.GetType",
|
||||
"GetUnspentCoins": "Neo.Transaction.GetUnspentCoins",
|
||||
"GetWitnesses": "Neo.Transaction.GetWitnesses",
|
||||
},
|
||||
|
|
|
@ -45,7 +45,7 @@ func TestNeoBlock_Setters(t *testing.T) {
|
|||
b.Block.PrevHash = util.Uint256{9, 8, 7}
|
||||
require.Equal(t, util.Uint256{9, 8, 7}, b.PrevHash())
|
||||
|
||||
txx := []block.Transaction{transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 1)}
|
||||
txx := []block.Transaction{transaction.New([]byte{byte(opcode.PUSH1)}, 1)}
|
||||
b.SetTransactions(txx)
|
||||
require.Equal(t, txx, b.Transactions())
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ import (
|
|||
|
||||
func TestNewService(t *testing.T) {
|
||||
srv := newTestService(t)
|
||||
tx := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx := transaction.New([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx.ValidUntilBlock = 1
|
||||
addSender(t, tx)
|
||||
signTx(t, srv.Chain.FeePerByte(), tx)
|
||||
|
@ -40,7 +40,7 @@ func TestService_GetVerified(t *testing.T) {
|
|||
srv := newTestService(t)
|
||||
var txs []*transaction.Transaction
|
||||
for i := 0; i < 4; i++ {
|
||||
tx := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx := transaction.New([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx.Nonce = 123 + uint32(i)
|
||||
tx.ValidUntilBlock = 1
|
||||
txs = append(txs, tx)
|
||||
|
@ -54,7 +54,7 @@ func TestService_GetVerified(t *testing.T) {
|
|||
p := new(Payload)
|
||||
p.message = &message{}
|
||||
p.SetType(payload.PrepareRequestType)
|
||||
tx := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx := transaction.New([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx.Nonce = 999
|
||||
p.SetPayload(&prepareRequest{transactionHashes: hashes})
|
||||
p.SetValidatorIndex(1)
|
||||
|
@ -121,7 +121,7 @@ func TestService_getTx(t *testing.T) {
|
|||
srv := newTestService(t)
|
||||
|
||||
t.Run("transaction in mempool", func(t *testing.T) {
|
||||
tx := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx := transaction.New([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx.Nonce = 1234
|
||||
tx.ValidUntilBlock = 1
|
||||
addSender(t, tx)
|
||||
|
@ -138,7 +138,7 @@ func TestService_getTx(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("transaction in local cache", func(t *testing.T) {
|
||||
tx := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx := transaction.New([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx.Nonce = 4321
|
||||
tx.ValidUntilBlock = 1
|
||||
h := tx.Hash()
|
||||
|
|
|
@ -85,7 +85,7 @@ func newDumbBlock() *Block {
|
|||
Nonce: 1111,
|
||||
},
|
||||
Transactions: []*transaction.Transaction{
|
||||
transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0),
|
||||
transaction.New([]byte{byte(opcode.PUSH1)}, 0),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -363,20 +363,18 @@ func (bc *Blockchain) notificationDispatcher() {
|
|||
if len(txFeed) != 0 || len(notificationFeed) != 0 || len(executionFeed) != 0 {
|
||||
var aerIdx int
|
||||
for _, tx := range event.block.Transactions {
|
||||
if tx.Type == transaction.InvocationType {
|
||||
aer := event.appExecResults[aerIdx]
|
||||
if !aer.TxHash.Equals(tx.Hash()) {
|
||||
panic("inconsistent application execution results")
|
||||
}
|
||||
aerIdx++
|
||||
for ch := range executionFeed {
|
||||
ch <- aer
|
||||
}
|
||||
if aer.VMState == "HALT" {
|
||||
for i := range aer.Events {
|
||||
for ch := range notificationFeed {
|
||||
ch <- &aer.Events[i]
|
||||
}
|
||||
aer := event.appExecResults[aerIdx]
|
||||
if !aer.TxHash.Equals(tx.Hash()) {
|
||||
panic("inconsistent application execution results")
|
||||
}
|
||||
aerIdx++
|
||||
for ch := range executionFeed {
|
||||
ch <- aer
|
||||
}
|
||||
if aer.VMState == "HALT" {
|
||||
for i := range aer.Events {
|
||||
for ch := range notificationFeed {
|
||||
ch <- &aer.Events[i]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -620,79 +618,75 @@ func (bc *Blockchain) storeBlock(block *block.Block) error {
|
|||
}
|
||||
}
|
||||
|
||||
// Process the underlying type of the TX.
|
||||
switch t := tx.Data.(type) {
|
||||
case *transaction.InvocationTX:
|
||||
systemInterop := bc.newInteropContext(trigger.Application, cache, block, tx)
|
||||
v := SpawnVM(systemInterop)
|
||||
v.LoadScript(t.Script)
|
||||
v.SetPriceGetter(getPrice)
|
||||
if bc.config.FreeGasLimit > 0 {
|
||||
v.SetGasLimit(bc.config.FreeGasLimit + tx.SystemFee)
|
||||
}
|
||||
systemInterop := bc.newInteropContext(trigger.Application, cache, block, tx)
|
||||
v := SpawnVM(systemInterop)
|
||||
v.LoadScript(tx.Script)
|
||||
v.SetPriceGetter(getPrice)
|
||||
if bc.config.FreeGasLimit > 0 {
|
||||
v.SetGasLimit(bc.config.FreeGasLimit + tx.SystemFee)
|
||||
}
|
||||
|
||||
err := v.Run()
|
||||
if !v.HasFailed() {
|
||||
_, err := systemInterop.DAO.Persist()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to persist invocation results")
|
||||
}
|
||||
for _, note := range systemInterop.Notifications {
|
||||
arr, ok := note.Item.Value().([]vm.StackItem)
|
||||
if !ok || len(arr) != 4 {
|
||||
continue
|
||||
}
|
||||
op, ok := arr[0].Value().([]byte)
|
||||
if !ok || (string(op) != "transfer" && string(op) != "Transfer") {
|
||||
continue
|
||||
}
|
||||
var from []byte
|
||||
fromValue := arr[1].Value()
|
||||
// we don't have `from` set when we are minting tokens
|
||||
if fromValue != nil {
|
||||
from, ok = fromValue.([]byte)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
}
|
||||
var to []byte
|
||||
toValue := arr[2].Value()
|
||||
// we don't have `to` set when we are burning tokens
|
||||
if toValue != nil {
|
||||
to, ok = toValue.([]byte)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
}
|
||||
amount, ok := arr[3].Value().(*big.Int)
|
||||
if !ok {
|
||||
bs, ok := arr[3].Value().([]byte)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
amount = emit.BytesToInt(bs)
|
||||
}
|
||||
bc.processNEP5Transfer(cache, tx, block, note.ScriptHash, from, to, amount.Int64())
|
||||
}
|
||||
} else {
|
||||
bc.log.Warn("contract invocation failed",
|
||||
zap.String("tx", tx.Hash().StringLE()),
|
||||
zap.Uint32("block", block.Index),
|
||||
zap.Error(err))
|
||||
}
|
||||
aer := &state.AppExecResult{
|
||||
TxHash: tx.Hash(),
|
||||
Trigger: trigger.Application,
|
||||
VMState: v.State(),
|
||||
GasConsumed: v.GasConsumed(),
|
||||
Stack: v.Estack().ToContractParameters(),
|
||||
Events: systemInterop.Notifications,
|
||||
}
|
||||
appExecResults = append(appExecResults, aer)
|
||||
err = cache.PutAppExecResult(aer)
|
||||
err := v.Run()
|
||||
if !v.HasFailed() {
|
||||
_, err := systemInterop.DAO.Persist()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to Store notifications")
|
||||
return errors.Wrap(err, "failed to persist invocation results")
|
||||
}
|
||||
for _, note := range systemInterop.Notifications {
|
||||
arr, ok := note.Item.Value().([]vm.StackItem)
|
||||
if !ok || len(arr) != 4 {
|
||||
continue
|
||||
}
|
||||
op, ok := arr[0].Value().([]byte)
|
||||
if !ok || (string(op) != "transfer" && string(op) != "Transfer") {
|
||||
continue
|
||||
}
|
||||
var from []byte
|
||||
fromValue := arr[1].Value()
|
||||
// we don't have `from` set when we are minting tokens
|
||||
if fromValue != nil {
|
||||
from, ok = fromValue.([]byte)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
}
|
||||
var to []byte
|
||||
toValue := arr[2].Value()
|
||||
// we don't have `to` set when we are burning tokens
|
||||
if toValue != nil {
|
||||
to, ok = toValue.([]byte)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
}
|
||||
amount, ok := arr[3].Value().(*big.Int)
|
||||
if !ok {
|
||||
bs, ok := arr[3].Value().([]byte)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
amount = emit.BytesToInt(bs)
|
||||
}
|
||||
bc.processNEP5Transfer(cache, tx, block, note.ScriptHash, from, to, amount.Int64())
|
||||
}
|
||||
} else {
|
||||
bc.log.Warn("contract invocation failed",
|
||||
zap.String("tx", tx.Hash().StringLE()),
|
||||
zap.Uint32("block", block.Index),
|
||||
zap.Error(err))
|
||||
}
|
||||
aer := &state.AppExecResult{
|
||||
TxHash: tx.Hash(),
|
||||
Trigger: trigger.Application,
|
||||
VMState: v.State(),
|
||||
GasConsumed: v.GasConsumed(),
|
||||
Stack: v.Estack().ToContractParameters(),
|
||||
Events: systemInterop.Notifications,
|
||||
}
|
||||
appExecResults = append(appExecResults, aer)
|
||||
err = cache.PutAppExecResult(aer)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to Store notifications")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -102,7 +102,7 @@ func TestScriptFromWitness(t *testing.T) {
|
|||
|
||||
func TestGetHeader(t *testing.T) {
|
||||
bc := newTestChain(t)
|
||||
tx := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx := transaction.New([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx.ValidUntilBlock = bc.BlockHeight() + 1
|
||||
assert.Nil(t, addSender(tx))
|
||||
assert.Nil(t, signTx(bc, tx))
|
||||
|
@ -267,7 +267,7 @@ func TestSubscriptions(t *testing.T) {
|
|||
emit.Bytes(script.BinWriter, []byte("yay!"))
|
||||
emit.Syscall(script.BinWriter, "Neo.Runtime.Notify")
|
||||
require.NoError(t, script.Err)
|
||||
txGood1 := transaction.NewInvocationTX(script.Bytes(), 0)
|
||||
txGood1 := transaction.New(script.Bytes(), 0)
|
||||
txGood1.Sender = neoOwner
|
||||
txGood1.Nonce = 1
|
||||
txGood1.ValidUntilBlock = 100500
|
||||
|
@ -279,7 +279,7 @@ func TestSubscriptions(t *testing.T) {
|
|||
emit.Syscall(script.BinWriter, "Neo.Runtime.Notify")
|
||||
emit.Opcode(script.BinWriter, opcode.THROW)
|
||||
require.NoError(t, script.Err)
|
||||
txBad := transaction.NewInvocationTX(script.Bytes(), 0)
|
||||
txBad := transaction.New(script.Bytes(), 0)
|
||||
txBad.Sender = neoOwner
|
||||
txBad.Nonce = 2
|
||||
txBad.ValidUntilBlock = 100500
|
||||
|
@ -289,7 +289,7 @@ func TestSubscriptions(t *testing.T) {
|
|||
emit.Bytes(script.BinWriter, []byte("yay! yay! yay!"))
|
||||
emit.Syscall(script.BinWriter, "Neo.Runtime.Notify")
|
||||
require.NoError(t, script.Err)
|
||||
txGood2 := transaction.NewInvocationTX(script.Bytes(), 0)
|
||||
txGood2 := transaction.New(script.Bytes(), 0)
|
||||
txGood2.Sender = neoOwner
|
||||
txGood2.Nonce = 3
|
||||
txGood2.ValidUntilBlock = 100500
|
||||
|
@ -311,14 +311,11 @@ func TestSubscriptions(t *testing.T) {
|
|||
for _, txExpected := range invBlock.Transactions {
|
||||
tx := <-txCh
|
||||
require.Equal(t, txExpected, tx)
|
||||
if txExpected.Type == transaction.InvocationType {
|
||||
exec := <-executionCh
|
||||
require.Equal(t, tx.Hash(), exec.TxHash)
|
||||
if exec.VMState == "HALT" {
|
||||
notif := <-notificationCh
|
||||
inv := tx.Data.(*transaction.InvocationTX)
|
||||
require.Equal(t, hash.Hash160(inv.Script), notif.ScriptHash)
|
||||
}
|
||||
exec := <-executionCh
|
||||
require.Equal(t, tx.Hash(), exec.TxHash)
|
||||
if exec.VMState == "HALT" {
|
||||
notif := <-notificationCh
|
||||
require.Equal(t, hash.Hash160(tx.Script), notif.ScriptHash)
|
||||
}
|
||||
}
|
||||
assert.Empty(t, txCh)
|
||||
|
|
|
@ -220,7 +220,7 @@ func TestGetCurrentHeaderHeight_Store(t *testing.T) {
|
|||
|
||||
func TestStoreAsTransaction(t *testing.T) {
|
||||
dao := NewSimple(storage.NewMemoryStore())
|
||||
tx := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 1)
|
||||
tx := transaction.New([]byte{byte(opcode.PUSH1)}, 1)
|
||||
hash := tx.Hash()
|
||||
err := dao.StoreAsTransaction(tx, 0)
|
||||
require.NoError(t, err)
|
||||
|
|
|
@ -138,7 +138,7 @@ func newDumbBlock() *block.Block {
|
|||
Nonce: 1111,
|
||||
},
|
||||
Transactions: []*transaction.Transaction{
|
||||
transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0),
|
||||
transaction.New([]byte{byte(opcode.PUSH1)}, 0),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -240,7 +240,7 @@ func TestCreateBasicChain(t *testing.T) {
|
|||
txScript := script.Bytes()
|
||||
|
||||
invFee := util.Fixed8FromFloat(100)
|
||||
txDeploy := transaction.NewInvocationTX(txScript, invFee)
|
||||
txDeploy := transaction.New(txScript, invFee)
|
||||
txDeploy.Nonce = getNextNonce()
|
||||
txDeploy.ValidUntilBlock = validUntilBlock
|
||||
txDeploy.Sender = priv0ScriptHash
|
||||
|
@ -254,7 +254,7 @@ func TestCreateBasicChain(t *testing.T) {
|
|||
script = io.NewBufBinWriter()
|
||||
emit.AppCallWithOperationAndArgs(script.BinWriter, hash.Hash160(avm), "Put", "testkey", "testvalue")
|
||||
|
||||
txInv := transaction.NewInvocationTX(script.Bytes(), 0)
|
||||
txInv := transaction.New(script.Bytes(), 0)
|
||||
txInv.Nonce = getNextNonce()
|
||||
txInv.ValidUntilBlock = validUntilBlock
|
||||
txInv.Sender = priv0ScriptHash
|
||||
|
@ -285,7 +285,7 @@ func TestCreateBasicChain(t *testing.T) {
|
|||
sh := hash.Hash160(avm)
|
||||
w := io.NewBufBinWriter()
|
||||
emit.AppCallWithOperationAndArgs(w.BinWriter, sh, "init")
|
||||
initTx := transaction.NewInvocationTX(w.Bytes(), 0)
|
||||
initTx := transaction.New(w.Bytes(), 0)
|
||||
initTx.Nonce = getNextNonce()
|
||||
initTx.ValidUntilBlock = validUntilBlock
|
||||
initTx.Sender = priv0ScriptHash
|
||||
|
@ -375,7 +375,7 @@ func newNEP5Transfer(sc, from, to util.Uint160, amount int64) *transaction.Trans
|
|||
emit.Opcode(w.BinWriter, opcode.ASSERT)
|
||||
|
||||
script := w.Bytes()
|
||||
return transaction.NewInvocationTX(script, 0)
|
||||
return transaction.New(script, 0)
|
||||
}
|
||||
|
||||
func addSender(txs ...*transaction.Transaction) error {
|
||||
|
|
|
@ -152,17 +152,6 @@ func txGetReferences(ic *interop.Context, v *vm.VM) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// txGetType returns current transaction type.
|
||||
func txGetType(ic *interop.Context, v *vm.VM) error {
|
||||
txInterface := v.Estack().Pop().Value()
|
||||
tx, ok := txInterface.(*transaction.Transaction)
|
||||
if !ok {
|
||||
return errors.New("value is not a transaction")
|
||||
}
|
||||
v.Estack().PushVal(int(tx.Type))
|
||||
return nil
|
||||
}
|
||||
|
||||
// txGetUnspentCoins returns current transaction unspent coins.
|
||||
func txGetUnspentCoins(ic *interop.Context, v *vm.VM) error {
|
||||
txInterface := v.Estack().Pop().Value()
|
||||
|
@ -206,24 +195,6 @@ func txGetWitnesses(ic *interop.Context, v *vm.VM) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// invocationTx_GetScript returns invocation script from the current transaction.
|
||||
func invocationTxGetScript(ic *interop.Context, v *vm.VM) error {
|
||||
txInterface := v.Estack().Pop().Value()
|
||||
tx, ok := txInterface.(*transaction.Transaction)
|
||||
if !ok {
|
||||
return errors.New("value is not a transaction")
|
||||
}
|
||||
inv, ok := tx.Data.(*transaction.InvocationTX)
|
||||
if tx.Type != transaction.InvocationType || !ok {
|
||||
return errors.New("value is not an invocation transaction")
|
||||
}
|
||||
// It's important not to share inv.Script slice with the code running in VM.
|
||||
script := make([]byte, len(inv.Script))
|
||||
copy(script, inv.Script)
|
||||
v.Estack().PushVal(script)
|
||||
return nil
|
||||
}
|
||||
|
||||
// witnessGetVerificationScript returns current witness' script.
|
||||
func witnessGetVerificationScript(ic *interop.Context, v *vm.VM) error {
|
||||
witInterface := v.Estack().Pop().Value()
|
||||
|
|
|
@ -212,27 +212,6 @@ func TestTxGetOutputs(t *testing.T) {
|
|||
require.Equal(t, tx.Outputs[0], *value[0].Value().(*transaction.Output))
|
||||
}
|
||||
|
||||
func TestTxGetType(t *testing.T) {
|
||||
v, tx, context, chain := createVMAndPushTX(t)
|
||||
defer chain.Close()
|
||||
|
||||
err := txGetType(context, v)
|
||||
require.NoError(t, err)
|
||||
value := v.Estack().Pop().Value().(*big.Int)
|
||||
require.Equal(t, big.NewInt(int64(tx.Type)), value)
|
||||
}
|
||||
|
||||
func TestInvocationTxGetScript(t *testing.T) {
|
||||
v, tx, context, chain := createVMAndPushTX(t)
|
||||
defer chain.Close()
|
||||
|
||||
err := invocationTxGetScript(context, v)
|
||||
require.NoError(t, err)
|
||||
value := v.Estack().Pop().Value().([]byte)
|
||||
inv := tx.Data.(*transaction.InvocationTX)
|
||||
require.Equal(t, inv.Script, value)
|
||||
}
|
||||
|
||||
func TestWitnessGetVerificationScript(t *testing.T) {
|
||||
v := vm.New()
|
||||
script := []byte{byte(opcode.PUSHM1), byte(opcode.RET)}
|
||||
|
@ -290,14 +269,14 @@ func TestECDSAVerify(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("signed interop item", func(t *testing.T) {
|
||||
tx := transaction.NewInvocationTX([]byte{0, 1, 2}, 1)
|
||||
tx := transaction.New([]byte{0, 1, 2}, 1)
|
||||
msg := tx.GetSignedPart()
|
||||
sign := priv.Sign(msg)
|
||||
runCase(t, false, true, sign, priv.PublicKey().Bytes(), vm.NewInteropItem(tx))
|
||||
})
|
||||
|
||||
t.Run("signed script container", func(t *testing.T) {
|
||||
tx := transaction.NewInvocationTX([]byte{0, 1, 2}, 1)
|
||||
tx := transaction.New([]byte{0, 1, 2}, 1)
|
||||
msg := tx.GetSignedPart()
|
||||
sign := priv.Sign(msg)
|
||||
ic.Container = tx
|
||||
|
@ -617,7 +596,7 @@ func createVMAndAccState(t *testing.T) (*vm.VM, *state.Account, *interop.Context
|
|||
func createVMAndTX(t *testing.T) (*vm.VM, *transaction.Transaction, *interop.Context, *Blockchain) {
|
||||
v := vm.New()
|
||||
script := []byte{byte(opcode.PUSH1), byte(opcode.RET)}
|
||||
tx := transaction.NewInvocationTX(script, 0)
|
||||
tx := transaction.New(script, 0)
|
||||
|
||||
bytes := make([]byte, 1)
|
||||
attributes := append(tx.Attributes, transaction.Attribute{
|
||||
|
|
|
@ -150,7 +150,6 @@ var neoInterops = []interop.Function{
|
|||
{Name: "Neo.Header.GetVersion", Func: headerGetVersion, Price: 1},
|
||||
{Name: "Neo.Input.GetHash", Func: inputGetHash, Price: 1},
|
||||
{Name: "Neo.Input.GetIndex", Func: inputGetIndex, Price: 1},
|
||||
{Name: "Neo.InvocationTransaction.GetScript", Func: invocationTxGetScript, Price: 1},
|
||||
{Name: "Neo.Iterator.Concat", Func: iterator.Concat, Price: 1},
|
||||
{Name: "Neo.Iterator.Create", Func: iterator.Create, Price: 1},
|
||||
{Name: "Neo.Iterator.Key", Func: iterator.Key, Price: 1},
|
||||
|
@ -179,7 +178,6 @@ var neoInterops = []interop.Function{
|
|||
{Name: "Neo.Transaction.GetInputs", Func: txGetInputs, Price: 1},
|
||||
{Name: "Neo.Transaction.GetOutputs", Func: txGetOutputs, Price: 1},
|
||||
{Name: "Neo.Transaction.GetReferences", Func: txGetReferences, Price: 200},
|
||||
{Name: "Neo.Transaction.GetType", Func: txGetType, Price: 1},
|
||||
{Name: "Neo.Transaction.GetUnspentCoins", Func: txGetUnspentCoins, Price: 200},
|
||||
{Name: "Neo.Transaction.GetWitnesses", Func: txGetWitnesses, Price: 200},
|
||||
{Name: "Neo.Witness.GetVerificationScript", Func: witnessGetVerificationScript, Price: 100},
|
||||
|
@ -241,7 +239,6 @@ var neoInterops = []interop.Function{
|
|||
{Name: "AntShares.Transaction.GetInputs", Func: txGetInputs, Price: 1},
|
||||
{Name: "AntShares.Transaction.GetOutputs", Func: txGetOutputs, Price: 1},
|
||||
{Name: "AntShares.Transaction.GetReferences", Func: txGetReferences, Price: 200},
|
||||
{Name: "AntShares.Transaction.GetType", Func: txGetType, Price: 1},
|
||||
}
|
||||
|
||||
// initIDinInteropsSlice initializes IDs from names in one given
|
||||
|
|
|
@ -60,7 +60,6 @@ func TestUnexpectedNonInterops(t *testing.T) {
|
|||
headerGetVersion,
|
||||
inputGetHash,
|
||||
inputGetIndex,
|
||||
invocationTxGetScript,
|
||||
outputGetAssetID,
|
||||
outputGetScriptHash,
|
||||
outputGetValue,
|
||||
|
@ -75,7 +74,6 @@ func TestUnexpectedNonInterops(t *testing.T) {
|
|||
txGetInputs,
|
||||
txGetOutputs,
|
||||
txGetReferences,
|
||||
txGetType,
|
||||
txGetUnspentCoins,
|
||||
txGetWitnesses,
|
||||
witnessGetVerificationScript,
|
||||
|
|
|
@ -31,7 +31,7 @@ func (fs *FeerStub) GetUtilityTokenBalance(uint160 util.Uint160) util.Fixed8 {
|
|||
|
||||
func testMemPoolAddRemoveWithFeer(t *testing.T, fs Feer) {
|
||||
mp := NewMemPool(10)
|
||||
tx := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx := transaction.New([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx.Nonce = 0
|
||||
_, _, ok := mp.TryGetValue(tx.Hash())
|
||||
require.Equal(t, false, ok)
|
||||
|
@ -65,7 +65,7 @@ func TestMemPoolAddRemoveWithInputs(t *testing.T) {
|
|||
mpLessInputs := func(i, j int) bool {
|
||||
return mp.inputs[i].Cmp(mp.inputs[j]) < 0
|
||||
}
|
||||
txm1 := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0)
|
||||
txm1 := transaction.New([]byte{byte(opcode.PUSH1)}, 0)
|
||||
txm1.Nonce = 1
|
||||
for i := 0; i < 5; i++ {
|
||||
txm1.Inputs = append(txm1.Inputs, transaction.Input{PrevHash: hash1, PrevIndex: uint16(100 - i)})
|
||||
|
@ -75,7 +75,7 @@ func TestMemPoolAddRemoveWithInputs(t *testing.T) {
|
|||
assert.Equal(t, len(txm1.Inputs), len(mp.inputs))
|
||||
assert.True(t, sort.SliceIsSorted(mp.inputs, mpLessInputs))
|
||||
|
||||
txm2 := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0)
|
||||
txm2 := transaction.New([]byte{byte(opcode.PUSH1)}, 0)
|
||||
txm2.Nonce = 1
|
||||
for i := 0; i < 10; i++ {
|
||||
txm2.Inputs = append(txm2.Inputs, transaction.Input{PrevHash: hash2, PrevIndex: uint16(i)})
|
||||
|
@ -104,21 +104,21 @@ func TestMemPoolAddRemoveWithInputs(t *testing.T) {
|
|||
|
||||
func TestMemPoolVerifyInputs(t *testing.T) {
|
||||
mp := NewMemPool(10)
|
||||
tx := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx := transaction.New([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx.Nonce = 1
|
||||
inhash1 := random.Uint256()
|
||||
tx.Inputs = append(tx.Inputs, transaction.Input{PrevHash: inhash1, PrevIndex: 0})
|
||||
require.Equal(t, true, mp.Verify(tx, &FeerStub{}))
|
||||
require.NoError(t, mp.Add(tx, &FeerStub{}))
|
||||
|
||||
tx2 := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx2 := transaction.New([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx2.Nonce = 2
|
||||
inhash2 := random.Uint256()
|
||||
tx2.Inputs = append(tx2.Inputs, transaction.Input{PrevHash: inhash2, PrevIndex: 0})
|
||||
require.Equal(t, true, mp.Verify(tx2, &FeerStub{}))
|
||||
require.NoError(t, mp.Add(tx2, &FeerStub{}))
|
||||
|
||||
tx3 := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx3 := transaction.New([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx3.Nonce = 3
|
||||
// Different index number, but the same PrevHash as in tx1.
|
||||
tx3.Inputs = append(tx3.Inputs, transaction.Input{PrevHash: inhash1, PrevIndex: 1})
|
||||
|
@ -135,7 +135,7 @@ func TestOverCapacity(t *testing.T) {
|
|||
mp := NewMemPool(mempoolSize)
|
||||
|
||||
for i := 0; i < mempoolSize; i++ {
|
||||
tx := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx := transaction.New([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx.Nonce = uint32(i)
|
||||
require.NoError(t, mp.Add(tx, fs))
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ func TestOverCapacity(t *testing.T) {
|
|||
|
||||
// Fees are also prioritized.
|
||||
for i := 0; i < mempoolSize; i++ {
|
||||
tx := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx := transaction.New([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx.Attributes = append(tx.Attributes, transaction.Attribute{
|
||||
Usage: transaction.Hash1,
|
||||
Data: util.Uint256{1, 2, 3, 4}.BytesBE(),
|
||||
|
@ -159,7 +159,7 @@ func TestOverCapacity(t *testing.T) {
|
|||
require.Equal(t, true, sort.IsSorted(sort.Reverse(mp.verifiedTxes)))
|
||||
}
|
||||
// Less prioritized txes are not allowed anymore.
|
||||
tx := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx := transaction.New([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx.Attributes = append(tx.Attributes, transaction.Attribute{
|
||||
Usage: transaction.Hash1,
|
||||
Data: util.Uint256{1, 2, 3, 4}.BytesBE(),
|
||||
|
@ -172,7 +172,7 @@ func TestOverCapacity(t *testing.T) {
|
|||
require.Equal(t, true, sort.IsSorted(sort.Reverse(mp.verifiedTxes)))
|
||||
|
||||
// Low net fee, but higher per-byte fee is still a better combination.
|
||||
tx = transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx = transaction.New([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx.Nonce = txcnt
|
||||
tx.NetworkFee = util.Fixed8FromFloat(0.00007)
|
||||
txcnt++
|
||||
|
@ -185,7 +185,7 @@ func TestOverCapacity(t *testing.T) {
|
|||
// High priority always wins over low priority.
|
||||
fs.lowPriority = false
|
||||
for i := 0; i < mempoolSize; i++ {
|
||||
tx := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx := transaction.New([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx.Nonce = txcnt
|
||||
txcnt++
|
||||
require.NoError(t, mp.Add(tx, fs))
|
||||
|
@ -194,7 +194,7 @@ func TestOverCapacity(t *testing.T) {
|
|||
}
|
||||
// Good luck with low priority now.
|
||||
fs.lowPriority = true
|
||||
tx = transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx = transaction.New([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx.Nonce = txcnt
|
||||
require.Error(t, mp.Add(tx, fs))
|
||||
require.Equal(t, mempoolSize, mp.Count())
|
||||
|
@ -208,7 +208,7 @@ func TestGetVerified(t *testing.T) {
|
|||
|
||||
txes := make([]*transaction.Transaction, 0, mempoolSize)
|
||||
for i := 0; i < mempoolSize; i++ {
|
||||
tx := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx := transaction.New([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx.Nonce = uint32(i)
|
||||
txes = append(txes, tx)
|
||||
require.NoError(t, mp.Add(tx, fs))
|
||||
|
@ -234,7 +234,7 @@ func TestRemoveStale(t *testing.T) {
|
|||
txes1 := make([]*transaction.Transaction, 0, mempoolSize/2)
|
||||
txes2 := make([]*transaction.Transaction, 0, mempoolSize/2)
|
||||
for i := 0; i < mempoolSize; i++ {
|
||||
tx := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx := transaction.New([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx.Nonce = uint32(i)
|
||||
if i%2 == 0 {
|
||||
txes1 = append(txes1, tx)
|
||||
|
@ -263,7 +263,7 @@ func TestRemoveStale(t *testing.T) {
|
|||
func TestMemPoolFees(t *testing.T) {
|
||||
mp := NewMemPool(10)
|
||||
sender0 := util.Uint160{1, 2, 3}
|
||||
tx0 := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx0 := transaction.New([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx0.NetworkFee = util.Fixed8FromInt64(11000)
|
||||
tx0.Sender = sender0
|
||||
// insufficient funds to add transaction, but balance should be stored
|
||||
|
@ -276,7 +276,7 @@ func TestMemPoolFees(t *testing.T) {
|
|||
}, mp.fees[sender0])
|
||||
|
||||
// no problems with adding another transaction with lower fee
|
||||
tx1 := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx1 := transaction.New([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx1.NetworkFee = util.Fixed8FromInt64(7000)
|
||||
tx1.Sender = sender0
|
||||
require.NoError(t, mp.Add(tx1, &FeerStub{}))
|
||||
|
@ -287,7 +287,7 @@ func TestMemPoolFees(t *testing.T) {
|
|||
}, mp.fees[sender0])
|
||||
|
||||
// balance shouldn't change after adding one more transaction
|
||||
tx2 := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx2 := transaction.New([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx2.NetworkFee = util.Fixed8FromFloat(3000)
|
||||
tx2.Sender = sender0
|
||||
require.NoError(t, mp.Add(tx2, &FeerStub{}))
|
||||
|
@ -299,7 +299,7 @@ func TestMemPoolFees(t *testing.T) {
|
|||
}, mp.fees[sender0])
|
||||
|
||||
// can't add more transactions as we don't have enough GAS
|
||||
tx3 := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx3 := transaction.New([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx3.NetworkFee = util.Fixed8FromFloat(0.5)
|
||||
tx3.Sender = sender0
|
||||
require.Equal(t, false, mp.Verify(tx3, &FeerStub{}))
|
||||
|
|
|
@ -92,7 +92,7 @@ func TestNativeContract_Invoke(t *testing.T) {
|
|||
w := io.NewBufBinWriter()
|
||||
emit.AppCallWithOperationAndArgs(w.BinWriter, tn.Metadata().Hash, "sum", int64(14), int64(28))
|
||||
script := w.Bytes()
|
||||
tx := transaction.NewInvocationTX(script, 0)
|
||||
tx := transaction.New(script, 0)
|
||||
validUntil := chain.blockHeight + 1
|
||||
tx.ValidUntilBlock = validUntil
|
||||
require.NoError(t, addSender(tx))
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
package transaction
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"math/rand"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/io"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
)
|
||||
|
||||
// InvocationTX represents a invocation transaction and is used to
|
||||
// deploy smart contract to the NEO blockchain.
|
||||
type InvocationTX struct {
|
||||
// Script output of the smart contract.
|
||||
Script []byte
|
||||
}
|
||||
|
||||
// NewInvocationTX returns a new invocation transaction.
|
||||
func NewInvocationTX(script []byte, gas util.Fixed8) *Transaction {
|
||||
return &Transaction{
|
||||
Type: InvocationType,
|
||||
Version: 1,
|
||||
Nonce: rand.Uint32(),
|
||||
Data: &InvocationTX{
|
||||
Script: script,
|
||||
},
|
||||
SystemFee: gas,
|
||||
Attributes: []Attribute{},
|
||||
Cosigners: []Cosigner{},
|
||||
Inputs: []Input{},
|
||||
Outputs: []Output{},
|
||||
Scripts: []Witness{},
|
||||
}
|
||||
}
|
||||
|
||||
// DecodeBinary implements Serializable interface.
|
||||
func (tx *InvocationTX) DecodeBinary(br *io.BinReader) {
|
||||
tx.Script = br.ReadVarBytes()
|
||||
if br.Err == nil && len(tx.Script) == 0 {
|
||||
br.Err = errors.New("no script")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// EncodeBinary implements Serializable interface.
|
||||
func (tx *InvocationTX) EncodeBinary(bw *io.BinWriter) {
|
||||
bw.WriteVarBytes(tx.Script)
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
package transaction
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"testing"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/internal/testserdes"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestInvocationZeroScript(t *testing.T) {
|
||||
// Zero-length script.
|
||||
in, err := hex.DecodeString("000000000000000000")
|
||||
require.NoError(t, err)
|
||||
|
||||
inv := &InvocationTX{}
|
||||
assert.Error(t, testserdes.DecodeBinary(in, inv))
|
||||
|
||||
// PUSH1 script.
|
||||
in, err = hex.DecodeString("01510000000000000000")
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.NoError(t, testserdes.DecodeBinary(in, inv))
|
||||
}
|
|
@ -4,7 +4,7 @@ import (
|
|||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
|
||||
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
||||
|
@ -26,9 +26,6 @@ const (
|
|||
|
||||
// Transaction is a process recorded in the NEO blockchain.
|
||||
type Transaction struct {
|
||||
// The type of the transaction.
|
||||
Type TXType
|
||||
|
||||
// The trading version which is currently 0.
|
||||
Version uint8
|
||||
|
||||
|
@ -48,9 +45,8 @@ type Transaction struct {
|
|||
// transaction should fail verification.
|
||||
ValidUntilBlock uint32
|
||||
|
||||
// Data specific to the type of the transaction.
|
||||
// This is always a pointer to a <Type>Transaction.
|
||||
Data TXer
|
||||
// Code to run in NeoVM for this transaction.
|
||||
Script []byte
|
||||
|
||||
// Transaction attributes.
|
||||
Attributes []Attribute
|
||||
|
@ -89,6 +85,22 @@ func NewTrimmedTX(hash util.Uint256) *Transaction {
|
|||
}
|
||||
}
|
||||
|
||||
// New returns a new transaction to execute given script and pay given system
|
||||
// fee.
|
||||
func New(script []byte, gas util.Fixed8) *Transaction {
|
||||
return &Transaction{
|
||||
Version: 0,
|
||||
Nonce: rand.Uint32(),
|
||||
Script: script,
|
||||
SystemFee: gas,
|
||||
Attributes: []Attribute{},
|
||||
Cosigners: []Cosigner{},
|
||||
Inputs: []Input{},
|
||||
Outputs: []Output{},
|
||||
Scripts: []Witness{},
|
||||
}
|
||||
}
|
||||
|
||||
// Hash returns the hash of the transaction.
|
||||
func (t *Transaction) Hash() util.Uint256 {
|
||||
if t.hash.Equals(util.Uint256{}) {
|
||||
|
@ -121,8 +133,11 @@ func (t *Transaction) AddInput(in *Input) {
|
|||
|
||||
// DecodeBinary implements Serializable interface.
|
||||
func (t *Transaction) DecodeBinary(br *io.BinReader) {
|
||||
t.Type = TXType(br.ReadB())
|
||||
t.Version = uint8(br.ReadB())
|
||||
if t.Version > 0 {
|
||||
br.Err = errors.New("only version 0 is supported")
|
||||
return
|
||||
}
|
||||
t.Nonce = br.ReadU32LE()
|
||||
t.Sender.DecodeBinary(br)
|
||||
t.SystemFee.DecodeBinary(br)
|
||||
|
@ -140,7 +155,6 @@ func (t *Transaction) DecodeBinary(br *io.BinReader) {
|
|||
return
|
||||
}
|
||||
t.ValidUntilBlock = br.ReadU32LE()
|
||||
t.decodeData(br)
|
||||
|
||||
br.ReadArray(&t.Attributes)
|
||||
|
||||
|
@ -154,6 +168,12 @@ func (t *Transaction) DecodeBinary(br *io.BinReader) {
|
|||
}
|
||||
}
|
||||
|
||||
t.Script = br.ReadVarBytes()
|
||||
if br.Err == nil && len(t.Script) == 0 {
|
||||
br.Err = errors.New("no script")
|
||||
return
|
||||
}
|
||||
|
||||
br.ReadArray(&t.Inputs)
|
||||
br.ReadArray(&t.Outputs)
|
||||
for i := range t.Outputs {
|
||||
|
@ -171,16 +191,6 @@ func (t *Transaction) DecodeBinary(br *io.BinReader) {
|
|||
}
|
||||
}
|
||||
|
||||
func (t *Transaction) decodeData(r *io.BinReader) {
|
||||
switch t.Type {
|
||||
case InvocationType:
|
||||
t.Data = &InvocationTX{}
|
||||
t.Data.(*InvocationTX).DecodeBinary(r)
|
||||
default:
|
||||
r.Err = fmt.Errorf("invalid TX type %x", t.Type)
|
||||
}
|
||||
}
|
||||
|
||||
// EncodeBinary implements Serializable interface.
|
||||
func (t *Transaction) EncodeBinary(bw *io.BinWriter) {
|
||||
t.encodeHashableFields(bw)
|
||||
|
@ -190,11 +200,10 @@ func (t *Transaction) EncodeBinary(bw *io.BinWriter) {
|
|||
// encodeHashableFields encodes the fields that are not used for
|
||||
// signing the transaction, which are all fields except the scripts.
|
||||
func (t *Transaction) encodeHashableFields(bw *io.BinWriter) {
|
||||
if t.Data == nil {
|
||||
bw.Err = errors.New("transaction has no data")
|
||||
if len(t.Script) == 0 {
|
||||
bw.Err = errors.New("transaction has no script")
|
||||
return
|
||||
}
|
||||
bw.WriteB(byte(t.Type))
|
||||
bw.WriteB(byte(t.Version))
|
||||
bw.WriteU32LE(t.Nonce)
|
||||
t.Sender.EncodeBinary(bw)
|
||||
|
@ -202,15 +211,13 @@ func (t *Transaction) encodeHashableFields(bw *io.BinWriter) {
|
|||
t.NetworkFee.EncodeBinary(bw)
|
||||
bw.WriteU32LE(t.ValidUntilBlock)
|
||||
|
||||
// Underlying TXer.
|
||||
t.Data.EncodeBinary(bw)
|
||||
|
||||
// Attributes
|
||||
bw.WriteArray(t.Attributes)
|
||||
|
||||
// Cosigners
|
||||
bw.WriteArray(t.Cosigners)
|
||||
|
||||
bw.WriteVarBytes(t.Script)
|
||||
// Inputs
|
||||
bw.WriteArray(t.Inputs)
|
||||
|
||||
|
@ -285,7 +292,6 @@ func (t *Transaction) FeePerByte() util.Fixed8 {
|
|||
type transactionJSON struct {
|
||||
TxID util.Uint256 `json:"txid"`
|
||||
Size int `json:"size"`
|
||||
Type TXType `json:"type"`
|
||||
Version uint8 `json:"version"`
|
||||
Nonce uint32 `json:"nonce"`
|
||||
Sender string `json:"sender"`
|
||||
|
@ -294,11 +300,10 @@ type transactionJSON struct {
|
|||
ValidUntilBlock uint32 `json:"valid_until_block"`
|
||||
Attributes []Attribute `json:"attributes"`
|
||||
Cosigners []Cosigner `json:"cosigners"`
|
||||
Script string `json:"script"`
|
||||
Inputs []Input `json:"vin"`
|
||||
Outputs []Output `json:"vout"`
|
||||
Scripts []Witness `json:"scripts"`
|
||||
|
||||
Script string `json:"script,omitempty"`
|
||||
}
|
||||
|
||||
// MarshalJSON implements json.Marshaler interface.
|
||||
|
@ -306,23 +311,19 @@ func (t *Transaction) MarshalJSON() ([]byte, error) {
|
|||
tx := transactionJSON{
|
||||
TxID: t.Hash(),
|
||||
Size: io.GetVarSize(t),
|
||||
Type: t.Type,
|
||||
Version: t.Version,
|
||||
Nonce: t.Nonce,
|
||||
Sender: address.Uint160ToString(t.Sender),
|
||||
ValidUntilBlock: t.ValidUntilBlock,
|
||||
Attributes: t.Attributes,
|
||||
Cosigners: t.Cosigners,
|
||||
Script: hex.EncodeToString(t.Script),
|
||||
Inputs: t.Inputs,
|
||||
Outputs: t.Outputs,
|
||||
Scripts: t.Scripts,
|
||||
SystemFee: t.SystemFee,
|
||||
NetworkFee: t.NetworkFee,
|
||||
}
|
||||
switch t.Type {
|
||||
case InvocationType:
|
||||
tx.Script = hex.EncodeToString(t.Data.(*InvocationTX).Script)
|
||||
}
|
||||
return json.Marshal(tx)
|
||||
}
|
||||
|
||||
|
@ -332,7 +333,6 @@ func (t *Transaction) UnmarshalJSON(data []byte) error {
|
|||
if err := json.Unmarshal(data, tx); err != nil {
|
||||
return err
|
||||
}
|
||||
t.Type = tx.Type
|
||||
t.Version = tx.Version
|
||||
t.Nonce = tx.Nonce
|
||||
t.ValidUntilBlock = tx.ValidUntilBlock
|
||||
|
@ -348,15 +348,9 @@ func (t *Transaction) UnmarshalJSON(data []byte) error {
|
|||
return errors.New("cannot unmarshal tx: bad sender")
|
||||
}
|
||||
t.Sender = sender
|
||||
switch tx.Type {
|
||||
case InvocationType:
|
||||
bytes, err := hex.DecodeString(tx.Script)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
t.Data = &InvocationTX{
|
||||
Script: bytes,
|
||||
}
|
||||
t.Script, err = hex.DecodeString(tx.Script)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if t.Hash() != tx.TxID {
|
||||
return errors.New("txid doesn't match transaction hash")
|
||||
|
|
|
@ -61,30 +61,32 @@ func TestDecodeEncodeInvocationTX(t *testing.T) {
|
|||
}
|
||||
*/
|
||||
|
||||
func TestNewInvocationTX(t *testing.T) {
|
||||
func TestNew(t *testing.T) {
|
||||
script := []byte{0x51}
|
||||
tx := NewInvocationTX(script, 1)
|
||||
txData := tx.Data.(*InvocationTX)
|
||||
assert.Equal(t, InvocationType, tx.Type)
|
||||
tx := New(script, 1)
|
||||
assert.Equal(t, util.Fixed8(1), tx.SystemFee)
|
||||
assert.Equal(t, script, txData.Script)
|
||||
assert.Equal(t, script, tx.Script)
|
||||
// Update hash fields to match tx2 that is gonna autoupdate them on decode.
|
||||
_ = tx.Hash()
|
||||
testserdes.EncodeDecodeBinary(t, tx, new(Transaction))
|
||||
}
|
||||
|
||||
func TestEncodingTXWithNoData(t *testing.T) {
|
||||
func TestEncodingTXWithNoScript(t *testing.T) {
|
||||
_, err := testserdes.EncodeBinary(new(Transaction))
|
||||
require.Error(t, err)
|
||||
}
|
||||
|
||||
func TestDecodingTXWithNoScript(t *testing.T) {
|
||||
txBin, err := hex.DecodeString("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
|
||||
require.NoError(t, err)
|
||||
err = testserdes.DecodeBinary(txBin, new(Transaction))
|
||||
require.Error(t, err)
|
||||
}
|
||||
|
||||
func TestMarshalUnmarshalJSONInvocationTX(t *testing.T) {
|
||||
tx := &Transaction{
|
||||
Type: InvocationType,
|
||||
Version: 3,
|
||||
Data: &InvocationTX{
|
||||
Script: []byte{1, 2, 3, 4},
|
||||
},
|
||||
Version: 0,
|
||||
Script: []byte{1, 2, 3, 4},
|
||||
Attributes: []Attribute{},
|
||||
Inputs: []Input{{
|
||||
PrevHash: util.Uint256{5, 6, 7, 8},
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
package transaction
|
||||
|
||||
import "github.com/nspcc-dev/neo-go/pkg/io"
|
||||
|
||||
// TXer is interface that can act as the underlying data of
|
||||
// a transaction.
|
||||
type TXer interface {
|
||||
io.Serializable
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
package transaction
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// TXType is the type of a transaction.
|
||||
type TXType uint8
|
||||
|
||||
// Constants for all valid transaction types.
|
||||
const (
|
||||
InvocationType TXType = 0xd1
|
||||
)
|
||||
|
||||
// String implements the stringer interface.
|
||||
func (t TXType) String() string {
|
||||
switch t {
|
||||
case InvocationType:
|
||||
return "InvocationTransaction"
|
||||
default:
|
||||
return "UnknownTransaction"
|
||||
}
|
||||
}
|
||||
|
||||
// MarshalJSON implements the json marshaller interface.
|
||||
func (t TXType) MarshalJSON() ([]byte, error) {
|
||||
return []byte(`"` + t.String() + `"`), nil
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements the json.Unmarshaler interface.
|
||||
func (t *TXType) UnmarshalJSON(data []byte) error {
|
||||
l := len(data)
|
||||
if l < 2 || data[0] != '"' || data[l-1] != '"' {
|
||||
return errors.New("wrong format")
|
||||
}
|
||||
var err error
|
||||
*t, err = TXTypeFromString(string(data[1 : l-1]))
|
||||
return err
|
||||
}
|
||||
|
||||
// TXTypeFromString searches for TXType by string name.
|
||||
func TXTypeFromString(jsonString string) (TXType, error) {
|
||||
switch jsonString = strings.TrimSpace(jsonString); jsonString {
|
||||
case "InvocationTransaction":
|
||||
return InvocationType, nil
|
||||
default:
|
||||
return 0, errors.New("unknown state")
|
||||
}
|
||||
}
|
|
@ -77,7 +77,7 @@ func deployNativeContracts() *transaction.Transaction {
|
|||
buf := io.NewBufBinWriter()
|
||||
emit.Syscall(buf.BinWriter, "Neo.Native.Deploy")
|
||||
script := buf.Bytes()
|
||||
tx := transaction.NewInvocationTX(script, 0)
|
||||
tx := transaction.New(script, 0)
|
||||
tx.Nonce = 0
|
||||
tx.Sender = hash.Hash160([]byte{byte(opcode.PUSH1)})
|
||||
tx.Scripts = []transaction.Witness{
|
||||
|
|
|
@ -20,7 +20,7 @@ func TestGenesisBlockMainNet(t *testing.T) {
|
|||
// have been changed. Consequently, hash of the genesis block has been changed.
|
||||
// Update expected genesis block hash for better times.
|
||||
// Old hash is "d42561e3d30e15be6400b6df2f328e02d2bf6354c41dce433bc57687c82144bf"
|
||||
expect := "30b7e37836146ef63ffdc28411c6c22153b69d8fb10b1d5b96ea662cfb19d2e8"
|
||||
expect := "2535d4b8b244c8a036ed356ee4448e041dc6e8f1d81abdcc7e3d0640c66f6cc8"
|
||||
assert.Equal(t, expect, block.Hash().StringLE())
|
||||
}
|
||||
|
||||
|
|
|
@ -21,18 +21,6 @@ func GetHash(t Transaction) []byte {
|
|||
return nil
|
||||
}
|
||||
|
||||
// GetType returns the type of the given transaction. Possible values:
|
||||
// MinerTransaction = 0x00
|
||||
// EnrollmentTransaction = 0x20
|
||||
// StateType = 0x90
|
||||
// AgencyTransaction = 0xb0
|
||||
// PublishTransaction = 0xd0
|
||||
// InvocationTransaction = 0xd1
|
||||
// It uses `Neo.Transaction.GetType` syscall.
|
||||
func GetType(t Transaction) byte {
|
||||
return 0x00
|
||||
}
|
||||
|
||||
// GetAttributes returns a slice of attributes for agiven transaction. Refer to
|
||||
// attribute package on how to use them. This function uses
|
||||
// `Neo.Transaction.GetAttributes` syscall.
|
||||
|
@ -69,13 +57,6 @@ func GetOutputs(t Transaction) []output.Output {
|
|||
return []output.Output{}
|
||||
}
|
||||
|
||||
// GetScript returns the script stored in a given Invocation transaction.
|
||||
// Calling it for any other Transaction type would lead to failure. It uses
|
||||
// `Neo.InvocationTransaction.GetScript` syscall.
|
||||
func GetScript(t Transaction) []byte {
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetWitnesses returns a slice of witnesses of a given Transaction. Refer to
|
||||
// witness package on how to use them. This function uses
|
||||
// `Neo.Transaction.GetWitnesses` syscall.
|
||||
|
|
|
@ -108,7 +108,7 @@ func (c *Client) CreateNEP5TransferTx(acc *wallet.Account, to util.Uint160, toke
|
|||
emit.Opcode(w.BinWriter, opcode.ASSERT)
|
||||
|
||||
script := w.Bytes()
|
||||
tx := transaction.NewInvocationTX(script, gas)
|
||||
tx := transaction.New(script, gas)
|
||||
tx.Sender = from
|
||||
tx.Cosigners = []transaction.Cosigner{
|
||||
{
|
||||
|
|
|
@ -423,7 +423,7 @@ func (c *Client) SignAndPushInvocationTx(script []byte, acc *wallet.Account, sys
|
|||
var txHash util.Uint256
|
||||
var err error
|
||||
|
||||
tx := transaction.NewInvocationTX(script, sysfee)
|
||||
tx := transaction.New(script, sysfee)
|
||||
tx.SystemFee = sysfee
|
||||
|
||||
validUntilBlock, err := c.CalculateValidUntilBlock()
|
||||
|
|
|
@ -31,17 +31,17 @@ type rpcClientTestCase struct {
|
|||
check func(t *testing.T, c *Client, result interface{})
|
||||
}
|
||||
|
||||
const hexB1 = "0000000028de4a34063483263ea9899827792bfdc4acf6b533e7294dbb4838b820e9a40b5a448a04e699901d0ed78a62d11e2d0754f152dce78e08c8227d95bdf1df932a3eefd85e0000000001000000abec5362f11e75b6e02e407bb98d63675d14384101fd08010c40585acaabe5810f6a4a42bb44d946494887b4d9286ca3ccbe626f240d60080fccb602d7c4eda9d1aeeb6958adbd604aa227cd7e9238e5ea1925bf57af4c8726270c40785af1caba4069090bbcf6cf2a4eae8dcf9d706f719c8681c6c8599d21052ea1e982f1c35ea8241580c67d5ac33426135ef44575636dafdc3fa769f1d7f09fd20c400222d67892af0cb6561faf5107013f11d24432ae0100b9313799c9fd5c8db0ca8da95e31500fdaea820b06a9bd822b42b8e6b7803182619f9da3b6402e48bd250c40d614157118af153bbb89642280b4bf55fc4873d3bfd7cef3f30946598caa227b566d6c9a116f23ef3c0b383ae1a756cb3a2e724936d22830fef486f3946ae76294130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b413073b3bb03005704000000000000d10102000000abec5362f11e75b6e02e407bb98d63675d1438410000000000000000f66a0d0000000000b0040000590218ddf5050c14316e851039019d39dfc2c37d6c3fee19fd5809870c14abec5362f11e75b6e02e407bb98d63675d14384113c00c087472616e736665720c14897720d8cd76f4f00abfa37c0edd889c208fde9b41627d5b52380001abec5362f11e75b6e02e407bb98d63675d14384101000001fd08010c4076ef230b83bf1964ed734fc264df284de8eedbdf0e6403389c812146d34535863142e50aa61f4c6a6a9140441a180aba10166a62a1030458ef9725144f4bc5670c40c122b669c1e3d4346bebe959ffc3c9551533f00ad3b42a512dce6b90fa62f5779f211f576d80c3883ebe3d50b854d472c91c2632ed9c2da7d932b5f6d37fdaa40c4089accd1ef5b0a489acd360c9da7bdd1ad52550b4384d5bb76052debc136680be18d00f4c9c3ac3d9c3e4914c01e6b70f2cc0efc625c5b55ebd656f0f1bb650bb0c407d8de81ebfea87a1bbf366ff472eccdaa6e82a1988d8832318f2f66c7fd2e61f91c4a856d2778215b4d45703728da8a487aa71e53740b603d17d8af7d1a3f7b694130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b413073b3bbd10103000000abec5362f11e75b6e02e407bb98d63675d1438410000000000000000967a0d0000000000b00400005d0300e87648170000000c14316e851039019d39dfc2c37d6c3fee19fd5809870c14abec5362f11e75b6e02e407bb98d63675d14384113c00c087472616e736665720c143b7d3711c6f0ccf9b1dca903d1bfa1d896f1238c41627d5b52380001abec5362f11e75b6e02e407bb98d63675d14384101000001fd08010c40cfb0f8c01f320069f8f826cc5e3a9538e4eee4d228f1f2c53028be61c2df99b4341005ff8f50bde0e4827c7b0828eab59faca6eb2315fd11cd802daf88354fc90c4022deeaf06116faad8d9665dbb504a0049bb9f5b57713c85bfd894e12d3d46a73617199ff0854e3d5dde0dece92d8f1fd496b78c71727cfc03819f1d109ef827e0c406f68afac9da6dc56172ae57f56c5f1f3767d12d1a0aee2fecae80133b8e725578639b2ab15f230ce528ed4c85dfcfa4b231d5ff4ecc48555e68adf45e2e475500c4042a504fae6914f86b1318a3e278e8ca18e92db7fa432f05364824ea96a95899a0b3c0b07a910a3782b17fc46bc2a6b31259d1d046fcc508d7873e90ec67cc70794130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b413073b3bb"
|
||||
const hexB1 = "000000001409900d6f330df2624b9ad49e4e68c04bab6757b684b4ae46e995ec9278002d6aa5da3b3922db2ae0fb51e6058d123d441650db8a187e7b7a34c55927fae217b91274847201000001000000abec5362f11e75b6e02e407bb98d63675d14384101fd08010c40bac8992a77bd21ba670f2bf5097387a42b227878b361c69bfeeeb55c4b68bdff7db5c93b8f6d84876e473bba84bf27dc7de8d35b8179e120a60a6bc01562ac740c401c876fdb2fbffc599ac9ffbc85f7e6087855fd40e12b23888718e381c93de2614cce5bdfb1108ff72a73b85d4a6556dad6578a59bfa0e61b93c775cb1c1924f20c40fd992b9d776da1d2da390915e743f4213ce8a6db862b6354cccbcb3bf8b4edd14562cb546cbbcb3e2d096c9e527d4ee7879c5bbfd01d9a2bb00a1986820e1c320c40fcf3d76b809078a872970bd3bde5836589a7f62660098bbfb82a1cb470b75cc480d527a3829de89c897bacc6c29dfc3e4b84368aa1f69c9bce704fb3399fc04e94130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b413073b3bb030057040000000000000002000000abec5362f11e75b6e02e407bb98d63675d14384100000000000000000e670d0000000000b00400000001abec5362f11e75b6e02e407bb98d63675d14384101590218ddf5050c14316e851039019d39dfc2c37d6c3fee19fd5809870c14abec5362f11e75b6e02e407bb98d63675d14384113c00c087472616e736665720c14897720d8cd76f4f00abfa37c0edd889c208fde9b41627d5b5238000001fd08010c4015b24aa11983bbf098384be4ebf5c283c3b4b2d2f6bf17b1a2a32f59627c7eb6370748b231acce2eb1ab5db3cdbf6943084634d12f69bf7b0aa447f96ebaf7d40c40a6777566463018e3f82fbbd370eef65b8454e50978401d1d97df05d9eda3b2bd5f5f882a94f8adbeaa2a55f64bd4ec23398fca26e8b364e5f57c771d71b3ec3d0c4032f5b1e3af669f4f14c2579de8f7ce46e30b35f7ed70892389251d50779477d2506b330dc9dd47f8c406218656d60b669479433bd9f762888091dc94415de5690c404b6ca943c34be335466c25ed442d17abc24d6a78db407a8c2a2c43fb911f0cbdbb28ec791b5f9de01b2db26105aa35193113a3a382c1ed02fbaf82b42468853a94130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b413073b3bb0003000000abec5362f11e75b6e02e407bb98d63675d1438410000000000000000ae760d0000000000b00400000001abec5362f11e75b6e02e407bb98d63675d143841015d0300e87648170000000c14316e851039019d39dfc2c37d6c3fee19fd5809870c14abec5362f11e75b6e02e407bb98d63675d14384113c00c087472616e736665720c143b7d3711c6f0ccf9b1dca903d1bfa1d896f1238c41627d5b5238000001fd08010c4001c81faa8317a390c211d5e03451ed852ff02ec6c401c450558bc90c60a01912c3e1018de98e7458f6f96c68aad71ffb0e92327fcdfa4aabb5ea5834ec7afbf10c40a84e9bc36ffbf18a1ee79254182d2939dd3a7b9278e13893856f187ab44dec259c8a15d4f449a21aa6970234d79d81fee0aca1807341b977ff66d503a78c82920c4085495bb8d86b95a4afc1659ce1d993e1a7843e3dcb19696ce0422294dadddc73438780d5bc629560f576e0e75cff062c03e237d4e609dfaa9869135e23a487650c40ae25f2c563b978f931c3a8b5a18854d9bb77abf48c7554f2008f97696caca180cd40d4d0e47b3f4d86082e631547d1a4729c7ed60dda64fab9cd9a2270dd113294130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b413073b3bb"
|
||||
|
||||
const hexTxMoveNeo = "d10102000000abec5362f11e75b6e02e407bb98d63675d1438410000000000000000f66a0d0000000000b0040000590218ddf5050c14316e851039019d39dfc2c37d6c3fee19fd5809870c14abec5362f11e75b6e02e407bb98d63675d14384113c00c087472616e736665720c14897720d8cd76f4f00abfa37c0edd889c208fde9b41627d5b52380001abec5362f11e75b6e02e407bb98d63675d14384101000001fd08010c4076ef230b83bf1964ed734fc264df284de8eedbdf0e6403389c812146d34535863142e50aa61f4c6a6a9140441a180aba10166a62a1030458ef9725144f4bc5670c40c122b669c1e3d4346bebe959ffc3c9551533f00ad3b42a512dce6b90fa62f5779f211f576d80c3883ebe3d50b854d472c91c2632ed9c2da7d932b5f6d37fdaa40c4089accd1ef5b0a489acd360c9da7bdd1ad52550b4384d5bb76052debc136680be18d00f4c9c3ac3d9c3e4914c01e6b70f2cc0efc625c5b55ebd656f0f1bb650bb0c407d8de81ebfea87a1bbf366ff472eccdaa6e82a1988d8832318f2f66c7fd2e61f91c4a856d2778215b4d45703728da8a487aa71e53740b603d17d8af7d1a3f7b694130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b413073b3bb"
|
||||
const hexTxMoveNeo = "0002000000abec5362f11e75b6e02e407bb98d63675d14384100000000000000000e670d0000000000b00400000001abec5362f11e75b6e02e407bb98d63675d14384101590218ddf5050c14316e851039019d39dfc2c37d6c3fee19fd5809870c14abec5362f11e75b6e02e407bb98d63675d14384113c00c087472616e736665720c14897720d8cd76f4f00abfa37c0edd889c208fde9b41627d5b5238000001fd08010c4015b24aa11983bbf098384be4ebf5c283c3b4b2d2f6bf17b1a2a32f59627c7eb6370748b231acce2eb1ab5db3cdbf6943084634d12f69bf7b0aa447f96ebaf7d40c40a6777566463018e3f82fbbd370eef65b8454e50978401d1d97df05d9eda3b2bd5f5f882a94f8adbeaa2a55f64bd4ec23398fca26e8b364e5f57c771d71b3ec3d0c4032f5b1e3af669f4f14c2579de8f7ce46e30b35f7ed70892389251d50779477d2506b330dc9dd47f8c406218656d60b669479433bd9f762888091dc94415de5690c404b6ca943c34be335466c25ed442d17abc24d6a78db407a8c2a2c43fb911f0cbdbb28ec791b5f9de01b2db26105aa35193113a3a382c1ed02fbaf82b42468853a94130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b413073b3bb"
|
||||
|
||||
const b1Verbose = `{"id":5,"jsonrpc":"2.0","result":{"size":1687,"nextblockhash":"0x96a0856f49798732e6eae4026a5f3e919b96250d847bcb3560d03bbad895c740","confirmations":4,"hash":"0xf7c3cecbe8fb15560c3113dd03911e52858a233b32cdc761ca03bc0721553424","version":0,"previousblockhash":"0x0ba4e920b83848bb4d29e733b5f6acc4fd2b79279889a93e26833406344ade28","merkleroot":"0x2a93dff1bd957d22c8088ee7dc52f154072d1ed1628ad70e1d9099e6048a445a","time":1591275326,"index":1,"nextconsensus":"AXSvJVzydxXuL9da4GVwK25zdesCrVKkHL","witnesses":[{"invocation":"0c40585acaabe5810f6a4a42bb44d946494887b4d9286ca3ccbe626f240d60080fccb602d7c4eda9d1aeeb6958adbd604aa227cd7e9238e5ea1925bf57af4c8726270c40785af1caba4069090bbcf6cf2a4eae8dcf9d706f719c8681c6c8599d21052ea1e982f1c35ea8241580c67d5ac33426135ef44575636dafdc3fa769f1d7f09fd20c400222d67892af0cb6561faf5107013f11d24432ae0100b9313799c9fd5c8db0ca8da95e31500fdaea820b06a9bd822b42b8e6b7803182619f9da3b6402e48bd250c40d614157118af153bbb89642280b4bf55fc4873d3bfd7cef3f30946598caa227b566d6c9a116f23ef3c0b383ae1a756cb3a2e724936d22830fef486f3946ae762","verification":"130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b413073b3bb"}],"consensus_data":{"primary":0,"nonce":"0000000000000457"},"tx":[{"txid":"0xf93ae1dbd2167e9b4a06431741297b351ac6a8ea3ae8892785c49f690a40b2c0","size":578,"type":"InvocationTransaction","version":1,"nonce":2,"sender":"AXSvJVzydxXuL9da4GVwK25zdesCrVKkHL","sys_fee":"0","net_fee":"0.0087935","valid_until_block":1200,"attributes":[],"cosigners":[{"account":"0x4138145d67638db97b402ee0b6751ef16253ecab","scopes":1}],"vin":[],"vout":[],"scripts":[{"invocation":"0c4076ef230b83bf1964ed734fc264df284de8eedbdf0e6403389c812146d34535863142e50aa61f4c6a6a9140441a180aba10166a62a1030458ef9725144f4bc5670c40c122b669c1e3d4346bebe959ffc3c9551533f00ad3b42a512dce6b90fa62f5779f211f576d80c3883ebe3d50b854d472c91c2632ed9c2da7d932b5f6d37fdaa40c4089accd1ef5b0a489acd360c9da7bdd1ad52550b4384d5bb76052debc136680be18d00f4c9c3ac3d9c3e4914c01e6b70f2cc0efc625c5b55ebd656f0f1bb650bb0c407d8de81ebfea87a1bbf366ff472eccdaa6e82a1988d8832318f2f66c7fd2e61f91c4a856d2778215b4d45703728da8a487aa71e53740b603d17d8af7d1a3f7b6","verification":"130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b413073b3bb"}],"script":"0218ddf5050c14316e851039019d39dfc2c37d6c3fee19fd5809870c14abec5362f11e75b6e02e407bb98d63675d14384113c00c087472616e736665720c14897720d8cd76f4f00abfa37c0edd889c208fde9b41627d5b5238"},{"txid":"0xe2caf7a9ce32a0daad81fd76f67aa64ffbe7cedf0fdeb8c57c466b6f5833bf0b","size":582,"type":"InvocationTransaction","version":1,"nonce":3,"sender":"AXSvJVzydxXuL9da4GVwK25zdesCrVKkHL","sys_fee":"0","net_fee":"0.0088335","valid_until_block":1200,"attributes":[],"cosigners":[{"account":"0x4138145d67638db97b402ee0b6751ef16253ecab","scopes":1}],"vin":[],"vout":[],"scripts":[{"invocation":"0c40cfb0f8c01f320069f8f826cc5e3a9538e4eee4d228f1f2c53028be61c2df99b4341005ff8f50bde0e4827c7b0828eab59faca6eb2315fd11cd802daf88354fc90c4022deeaf06116faad8d9665dbb504a0049bb9f5b57713c85bfd894e12d3d46a73617199ff0854e3d5dde0dece92d8f1fd496b78c71727cfc03819f1d109ef827e0c406f68afac9da6dc56172ae57f56c5f1f3767d12d1a0aee2fecae80133b8e725578639b2ab15f230ce528ed4c85dfcfa4b231d5ff4ecc48555e68adf45e2e475500c4042a504fae6914f86b1318a3e278e8ca18e92db7fa432f05364824ea96a95899a0b3c0b07a910a3782b17fc46bc2a6b31259d1d046fcc508d7873e90ec67cc707","verification":"130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b413073b3bb"}],"script":"0300e87648170000000c14316e851039019d39dfc2c37d6c3fee19fd5809870c14abec5362f11e75b6e02e407bb98d63675d14384113c00c087472616e736665720c143b7d3711c6f0ccf9b1dca903d1bfa1d896f1238c41627d5b5238"}]}}`
|
||||
const b1Verbose = `{"id":5,"jsonrpc":"2.0","result":{"size":1685,"nextblockhash":"0x14a61952de5bf47e2550bb97439de44ea60f79e052419e8b263b1b41d7065b0f","confirmations":4,"hash":"0xc826db8aa7a05fbd336eb0fca66efea7330cdc09cc8cf8e3cd9a3d9a87b751ac","version":0,"previousblockhash":"0x2d007892ec95e946aeb484b65767ab4bc0684e9ed49a4b62f20d336f0d900914","merkleroot":"0x17e2fa2759c5347a7b7e188adb5016443d128d05e651fbe02adb22393bdaa56a","time":1591360099001,"index":1,"nextconsensus":"AXSvJVzydxXuL9da4GVwK25zdesCrVKkHL","witnesses":[{"invocation":"0c40bac8992a77bd21ba670f2bf5097387a42b227878b361c69bfeeeb55c4b68bdff7db5c93b8f6d84876e473bba84bf27dc7de8d35b8179e120a60a6bc01562ac740c401c876fdb2fbffc599ac9ffbc85f7e6087855fd40e12b23888718e381c93de2614cce5bdfb1108ff72a73b85d4a6556dad6578a59bfa0e61b93c775cb1c1924f20c40fd992b9d776da1d2da390915e743f4213ce8a6db862b6354cccbcb3bf8b4edd14562cb546cbbcb3e2d096c9e527d4ee7879c5bbfd01d9a2bb00a1986820e1c320c40fcf3d76b809078a872970bd3bde5836589a7f62660098bbfb82a1cb470b75cc480d527a3829de89c897bacc6c29dfc3e4b84368aa1f69c9bce704fb3399fc04e","verification":"130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b413073b3bb"}],"consensus_data":{"primary":0,"nonce":"0000000000000457"},"tx":[{"txid":"0xd24f8ab43462f8a2f788fa9073b8b32b4417aeddea19dfcc8dfb543d68e90de5","size":577,"version":0,"nonce":2,"sender":"AXSvJVzydxXuL9da4GVwK25zdesCrVKkHL","sys_fee":"0","net_fee":"0.0087835","valid_until_block":1200,"attributes":[],"cosigners":[{"account":"0x4138145d67638db97b402ee0b6751ef16253ecab","scopes":1}],"script":"0218ddf5050c14316e851039019d39dfc2c37d6c3fee19fd5809870c14abec5362f11e75b6e02e407bb98d63675d14384113c00c087472616e736665720c14897720d8cd76f4f00abfa37c0edd889c208fde9b41627d5b5238","vin":[],"vout":[],"scripts":[{"invocation":"0c4015b24aa11983bbf098384be4ebf5c283c3b4b2d2f6bf17b1a2a32f59627c7eb6370748b231acce2eb1ab5db3cdbf6943084634d12f69bf7b0aa447f96ebaf7d40c40a6777566463018e3f82fbbd370eef65b8454e50978401d1d97df05d9eda3b2bd5f5f882a94f8adbeaa2a55f64bd4ec23398fca26e8b364e5f57c771d71b3ec3d0c4032f5b1e3af669f4f14c2579de8f7ce46e30b35f7ed70892389251d50779477d2506b330dc9dd47f8c406218656d60b669479433bd9f762888091dc94415de5690c404b6ca943c34be335466c25ed442d17abc24d6a78db407a8c2a2c43fb911f0cbdbb28ec791b5f9de01b2db26105aa35193113a3a382c1ed02fbaf82b42468853a","verification":"130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b413073b3bb"}]},{"txid":"0xf3304d751f7f6e871a610644529aa4f8fcc60a31592352eea54b86be472614f1","size":581,"version":0,"nonce":3,"sender":"AXSvJVzydxXuL9da4GVwK25zdesCrVKkHL","sys_fee":"0","net_fee":"0.0088235","valid_until_block":1200,"attributes":[],"cosigners":[{"account":"0x4138145d67638db97b402ee0b6751ef16253ecab","scopes":1}],"script":"0300e87648170000000c14316e851039019d39dfc2c37d6c3fee19fd5809870c14abec5362f11e75b6e02e407bb98d63675d14384113c00c087472616e736665720c143b7d3711c6f0ccf9b1dca903d1bfa1d896f1238c41627d5b5238","vin":[],"vout":[],"scripts":[{"invocation":"0c4001c81faa8317a390c211d5e03451ed852ff02ec6c401c450558bc90c60a01912c3e1018de98e7458f6f96c68aad71ffb0e92327fcdfa4aabb5ea5834ec7afbf10c40a84e9bc36ffbf18a1ee79254182d2939dd3a7b9278e13893856f187ab44dec259c8a15d4f449a21aa6970234d79d81fee0aca1807341b977ff66d503a78c82920c4085495bb8d86b95a4afc1659ce1d993e1a7843e3dcb19696ce0422294dadddc73438780d5bc629560f576e0e75cff062c03e237d4e609dfaa9869135e23a487650c40ae25f2c563b978f931c3a8b5a18854d9bb77abf48c7554f2008f97696caca180cd40d4d0e47b3f4d86082e631547d1a4729c7ed60dda64fab9cd9a2270dd1132","verification":"130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b413073b3bb"}]}]}}`
|
||||
|
||||
const hexHeader1 = "0000000028de4a34063483263ea9899827792bfdc4acf6b533e7294dbb4838b820e9a40b5a448a04e699901d0ed78a62d11e2d0754f152dce78e08c8227d95bdf1df932a3eefd85e0000000001000000abec5362f11e75b6e02e407bb98d63675d14384101fd08010c40585acaabe5810f6a4a42bb44d946494887b4d9286ca3ccbe626f240d60080fccb602d7c4eda9d1aeeb6958adbd604aa227cd7e9238e5ea1925bf57af4c8726270c40785af1caba4069090bbcf6cf2a4eae8dcf9d706f719c8681c6c8599d21052ea1e982f1c35ea8241580c67d5ac33426135ef44575636dafdc3fa769f1d7f09fd20c400222d67892af0cb6561faf5107013f11d24432ae0100b9313799c9fd5c8db0ca8da95e31500fdaea820b06a9bd822b42b8e6b7803182619f9da3b6402e48bd250c40d614157118af153bbb89642280b4bf55fc4873d3bfd7cef3f30946598caa227b566d6c9a116f23ef3c0b383ae1a756cb3a2e724936d22830fef486f3946ae76294130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b413073b3bb00"
|
||||
const hexHeader1 = "000000001409900d6f330df2624b9ad49e4e68c04bab6757b684b4ae46e995ec9278002d6aa5da3b3922db2ae0fb51e6058d123d441650db8a187e7b7a34c55927fae217b91274847201000001000000abec5362f11e75b6e02e407bb98d63675d14384101fd08010c40bac8992a77bd21ba670f2bf5097387a42b227878b361c69bfeeeb55c4b68bdff7db5c93b8f6d84876e473bba84bf27dc7de8d35b8179e120a60a6bc01562ac740c401c876fdb2fbffc599ac9ffbc85f7e6087855fd40e12b23888718e381c93de2614cce5bdfb1108ff72a73b85d4a6556dad6578a59bfa0e61b93c775cb1c1924f20c40fd992b9d776da1d2da390915e743f4213ce8a6db862b6354cccbcb3bf8b4edd14562cb546cbbcb3e2d096c9e527d4ee7879c5bbfd01d9a2bb00a1986820e1c320c40fcf3d76b809078a872970bd3bde5836589a7f62660098bbfb82a1cb470b75cc480d527a3829de89c897bacc6c29dfc3e4b84368aa1f69c9bce704fb3399fc04e94130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b413073b3bb00"
|
||||
|
||||
const header1Verbose = `{"id":5,"jsonrpc":"2.0","result":{"hash":"0xf7c3cecbe8fb15560c3113dd03911e52858a233b32cdc761ca03bc0721553424","size":518,"version":0,"previousblockhash":"0x0ba4e920b83848bb4d29e733b5f6acc4fd2b79279889a93e26833406344ade28","merkleroot":"0x2a93dff1bd957d22c8088ee7dc52f154072d1ed1628ad70e1d9099e6048a445a","time":1591275326,"index":1,"nextconsensus":"AXSvJVzydxXuL9da4GVwK25zdesCrVKkHL","witnesses":[{"invocation":"0c40585acaabe5810f6a4a42bb44d946494887b4d9286ca3ccbe626f240d60080fccb602d7c4eda9d1aeeb6958adbd604aa227cd7e9238e5ea1925bf57af4c8726270c40785af1caba4069090bbcf6cf2a4eae8dcf9d706f719c8681c6c8599d21052ea1e982f1c35ea8241580c67d5ac33426135ef44575636dafdc3fa769f1d7f09fd20c400222d67892af0cb6561faf5107013f11d24432ae0100b9313799c9fd5c8db0ca8da95e31500fdaea820b06a9bd822b42b8e6b7803182619f9da3b6402e48bd250c40d614157118af153bbb89642280b4bf55fc4873d3bfd7cef3f30946598caa227b566d6c9a116f23ef3c0b383ae1a756cb3a2e724936d22830fef486f3946ae762","verification":"130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b413073b3bb"}],"confirmations":6,"nextblockhash":"0x96a0856f49798732e6eae4026a5f3e919b96250d847bcb3560d03bbad895c740"}}`
|
||||
const header1Verbose = `{"id":5,"jsonrpc":"2.0","result":{"hash":"0xc826db8aa7a05fbd336eb0fca66efea7330cdc09cc8cf8e3cd9a3d9a87b751ac","size":518,"version":0,"previousblockhash":"0x2d007892ec95e946aeb484b65767ab4bc0684e9ed49a4b62f20d336f0d900914","merkleroot":"0x17e2fa2759c5347a7b7e188adb5016443d128d05e651fbe02adb22393bdaa56a","time":1591360099001,"index":1,"nextconsensus":"AXSvJVzydxXuL9da4GVwK25zdesCrVKkHL","witnesses":[{"invocation":"0c40bac8992a77bd21ba670f2bf5097387a42b227878b361c69bfeeeb55c4b68bdff7db5c93b8f6d84876e473bba84bf27dc7de8d35b8179e120a60a6bc01562ac740c401c876fdb2fbffc599ac9ffbc85f7e6087855fd40e12b23888718e381c93de2614cce5bdfb1108ff72a73b85d4a6556dad6578a59bfa0e61b93c775cb1c1924f20c40fd992b9d776da1d2da390915e743f4213ce8a6db862b6354cccbcb3bf8b4edd14562cb546cbbcb3e2d096c9e527d4ee7879c5bbfd01d9a2bb00a1986820e1c320c40fcf3d76b809078a872970bd3bde5836589a7f62660098bbfb82a1cb470b75cc480d527a3829de89c897bacc6c29dfc3e4b84368aa1f69c9bce704fb3399fc04e","verification":"130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b413073b3bb"}],"confirmations":6,"nextblockhash":"0x14a61952de5bf47e2550bb97439de44ea60f79e052419e8b263b1b41d7065b0f"}}`
|
||||
|
||||
const txMoveNeoVerbose = `{"id":5,"jsonrpc":"2.0","result":{"blockhash":"0xf7c3cecbe8fb15560c3113dd03911e52858a233b32cdc761ca03bc0721553424","confirmations":6,"blocktime":1591275326,"txid":"0xf93ae1dbd2167e9b4a06431741297b351ac6a8ea3ae8892785c49f690a40b2c0","size":578,"type":"InvocationTransaction","version":1,"nonce":2,"sender":"AXSvJVzydxXuL9da4GVwK25zdesCrVKkHL","sys_fee":"0","net_fee":"0.0087935","valid_until_block":1200,"attributes":[],"cosigners":[{"account":"0x4138145d67638db97b402ee0b6751ef16253ecab","scopes":1}],"vin":[],"vout":[],"scripts":[{"invocation":"0c4076ef230b83bf1964ed734fc264df284de8eedbdf0e6403389c812146d34535863142e50aa61f4c6a6a9140441a180aba10166a62a1030458ef9725144f4bc5670c40c122b669c1e3d4346bebe959ffc3c9551533f00ad3b42a512dce6b90fa62f5779f211f576d80c3883ebe3d50b854d472c91c2632ed9c2da7d932b5f6d37fdaa40c4089accd1ef5b0a489acd360c9da7bdd1ad52550b4384d5bb76052debc136680be18d00f4c9c3ac3d9c3e4914c01e6b70f2cc0efc625c5b55ebd656f0f1bb650bb0c407d8de81ebfea87a1bbf366ff472eccdaa6e82a1988d8832318f2f66c7fd2e61f91c4a856d2778215b4d45703728da8a487aa71e53740b603d17d8af7d1a3f7b6","verification":"130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b413073b3bb"}],"script":"0218ddf5050c14316e851039019d39dfc2c37d6c3fee19fd5809870c14abec5362f11e75b6e02e407bb98d63675d14384113c00c087472616e736665720c14897720d8cd76f4f00abfa37c0edd889c208fde9b41627d5b5238"}}`
|
||||
const txMoveNeoVerbose = `{"id":5,"jsonrpc":"2.0","result":{"blockhash":"0xc826db8aa7a05fbd336eb0fca66efea7330cdc09cc8cf8e3cd9a3d9a87b751ac","confirmations":6,"blocktime":1591360099001,"txid":"0xd24f8ab43462f8a2f788fa9073b8b32b4417aeddea19dfcc8dfb543d68e90de5","size":577,"version":0,"nonce":2,"sender":"AXSvJVzydxXuL9da4GVwK25zdesCrVKkHL","sys_fee":"0","net_fee":"0.0087835","valid_until_block":1200,"attributes":[],"cosigners":[{"account":"0x4138145d67638db97b402ee0b6751ef16253ecab","scopes":1}],"script":"0218ddf5050c14316e851039019d39dfc2c37d6c3fee19fd5809870c14abec5362f11e75b6e02e407bb98d63675d14384113c00c087472616e736665720c14897720d8cd76f4f00abfa37c0edd889c208fde9b41627d5b5238","vin":[],"vout":[],"scripts":[{"invocation":"0c4015b24aa11983bbf098384be4ebf5c283c3b4b2d2f6bf17b1a2a32f59627c7eb6370748b231acce2eb1ab5db3cdbf6943084634d12f69bf7b0aa447f96ebaf7d40c40a6777566463018e3f82fbbd370eef65b8454e50978401d1d97df05d9eda3b2bd5f5f882a94f8adbeaa2a55f64bd4ec23398fca26e8b364e5f57c771d71b3ec3d0c4032f5b1e3af669f4f14c2579de8f7ce46e30b35f7ed70892389251d50779477d2506b330dc9dd47f8c406218656d60b669479433bd9f762888091dc94415de5690c404b6ca943c34be335466c25ed442d17abc24d6a78db407a8c2a2c43fb911f0cbdbb28ec791b5f9de01b2db26105aa35193113a3a382c1ed02fbaf82b42468853a","verification":"130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b413073b3bb"}]}}`
|
||||
|
||||
// getResultBlock1 returns data for block number 1 which is used by several tests.
|
||||
func getResultBlock1() *result.Block {
|
||||
|
@ -54,14 +54,14 @@ func getResultBlock1() *result.Block {
|
|||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
b2Hash, err := util.Uint256DecodeStringLE("96a0856f49798732e6eae4026a5f3e919b96250d847bcb3560d03bbad895c740")
|
||||
b2Hash, err := util.Uint256DecodeStringLE("14a61952de5bf47e2550bb97439de44ea60f79e052419e8b263b1b41d7065b0f")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return &result.Block{
|
||||
Block: b,
|
||||
BlockMetadata: result.BlockMetadata{
|
||||
Size: 1687,
|
||||
Size: 1685,
|
||||
NextBlockHash: &b2Hash,
|
||||
Confirmations: 4,
|
||||
},
|
||||
|
@ -616,7 +616,7 @@ var rpcClientTestCases = map[string][]rpcClientTestCase{
|
|||
{
|
||||
name: "positive",
|
||||
invoke: func(c *Client) (interface{}, error) {
|
||||
return nil, c.SendRawTransaction(transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0))
|
||||
return nil, c.SendRawTransaction(transaction.New([]byte{byte(opcode.PUSH1)}, 0))
|
||||
},
|
||||
serverResponse: `{"jsonrpc":"2.0","id":1,"result":true}`,
|
||||
result: func(c *Client) interface{} {
|
||||
|
@ -737,7 +737,7 @@ var rpcClientErrorCases = map[string][]rpcClientErrorCase{
|
|||
{
|
||||
name: "sendrawtransaction_bad_server_answer",
|
||||
invoke: func(c *Client) (interface{}, error) {
|
||||
return nil, c.SendRawTransaction(transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0))
|
||||
return nil, c.SendRawTransaction(transaction.New([]byte{byte(opcode.PUSH1)}, 0))
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -1063,7 +1063,7 @@ var rpcClientErrorCases = map[string][]rpcClientErrorCase{
|
|||
{
|
||||
name: "sendrawtransaction_unmarshalling_error",
|
||||
invoke: func(c *Client) (interface{}, error) {
|
||||
return nil, c.SendRawTransaction(transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0))
|
||||
return nil, c.SendRawTransaction(transaction.New([]byte{byte(opcode.PUSH1)}, 0))
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
|
@ -117,8 +117,8 @@ func TestWSClientEvents(t *testing.T) {
|
|||
var events = []string{
|
||||
`{"jsonrpc":"2.0","method":"transaction_executed","params":[{"txid":"0xe1cd5e57e721d2a2e05fb1f08721b12057b25ab1dd7fd0f33ee1639932fdfad7","executions":[{"trigger":"Application","contract":"0x0000000000000000000000000000000000000000","vmstate":"HALT","gas_consumed":"2.291","stack":[],"notifications":[{"contract":"0x1b4357bff5a01bdf2a6581247cf9ed1e24629176","state":{"type":"Array","value":[{"type":"ByteArray","value":"636f6e74726163742063616c6c"},{"type":"ByteArray","value":"7472616e73666572"},{"type":"Array","value":[{"type":"ByteArray","value":"769162241eedf97c2481652adf1ba0f5bf57431b"},{"type":"ByteArray","value":"316e851039019d39dfc2c37d6c3fee19fd580987"},{"type":"Integer","value":"1000"}]}]}},{"contract":"0x1b4357bff5a01bdf2a6581247cf9ed1e24629176","state":{"type":"Array","value":[{"type":"ByteArray","value":"7472616e73666572"},{"type":"ByteArray","value":"769162241eedf97c2481652adf1ba0f5bf57431b"},{"type":"ByteArray","value":"316e851039019d39dfc2c37d6c3fee19fd580987"},{"type":"Integer","value":"1000"}]}}]}]}]}`,
|
||||
`{"jsonrpc":"2.0","method":"notification_from_execution","params":[{"contract":"0x1b4357bff5a01bdf2a6581247cf9ed1e24629176","state":{"type":"Array","value":[{"type":"ByteArray","value":"636f6e74726163742063616c6c"},{"type":"ByteArray","value":"7472616e73666572"},{"type":"Array","value":[{"type":"ByteArray","value":"769162241eedf97c2481652adf1ba0f5bf57431b"},{"type":"ByteArray","value":"316e851039019d39dfc2c37d6c3fee19fd580987"},{"type":"Integer","value":"1000"}]}]}}]}`,
|
||||
`{"jsonrpc":"2.0","method":"transaction_added","params":[{"txid":"0xd3c3104eb1c059985ddeacc3a149634c830b39cf3fa37f4a2f7af0e4980ff370","size":269,"type":"InvocationTransaction","version":1,"nonce":9,"sender":"ALHF9wsXZVEuCGgmDA6ZNsCLtrb4A1g4yG","sys_fee":"0","net_fee":"0.0036921","valid_until_block":1200,"attributes":[],"cosigners":[{"account":"0x870958fd19ee3f6c7dc3c2df399d013910856e31","scopes":1}],"vin":[],"vout":[],"scripts":[{"invocation":"0c40cf193534761a987324a355749f5e4ef8499ff5948df6ee8a4b9834cbe025103ad08a74a00e1e248c73f3d967b23d09af0d200d9cb742ec0aa911f7f783cbd2e0","verification":"0c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20b410a906ad4"}],"script":"01e8030c14316e851039019d39dfc2c37d6c3fee19fd5809870c14769162241eedf97c2481652adf1ba0f5bf57431b13c00c087472616e736665720c14769162241eedf97c2481652adf1ba0f5bf57431b41627d5b5238"}]}`,
|
||||
`{"jsonrpc":"2.0","method":"block_added","params":[{"hash":"0x3c99815f393807efd7a620a04eed66440a3c89d41ff18fd42c08f71784fc1c16","version":0,"previousblockhash":"0xb6533ac10e71fb02348af87c0a723131939ee08713a7f31075d24beb54100f1a","merkleroot":"0x7470df300c48107d36ffd3da09b155a35650f1020d019abb0c3abb7bf91a09e2","time":1590609889,"index":207,"nextconsensus":"AXSvJVzydxXuL9da4GVwK25zdesCrVKkHL","witnesses":[{"invocation":"0c4095dfc789359ca154c07f1bfdc28e0ac512f78156825efafd9b31a6a8009cef6339de6f8331aad35f6dc8af9a7723a07fb9319ccad54c91ab9be155964efa5f920c4067ac11066db9e47f64cf876e3d6dd07e28324d51b53faf2a42ccafc371050efbe0b5809c80672ea116a557bfbdbf789b7bca008064834db80c7c91a768bcec760c40aefd42910ad6a6f9c3ba17a5b38e8de7188d0b36972c47d3054715209ca79d9811beff9a762ebd1c78584ff3110222419b2cdba6c22bbcbb554195bf9df09bb30c40368c314b35b051a4a258828d3327e8c22053166eeb749d50a9a33e2620ba156042124979a1554524daf9f7b371ec0da5b41404a1b5e0d42fe0032859e114833c","verification":"130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b413073b3bb"}],"consensus_data":{"primary":0,"nonce":"0000000000000457"},"tx":[{"txid":"0xde4481fdbef5d3726d0052661f950e69e4594dd6589913c628e20c1413f85b74","size":196,"type":"InvocationTransaction","version":1,"nonce":8,"sender":"ALHF9wsXZVEuCGgmDA6ZNsCLtrb4A1g4yG","sys_fee":"0","net_fee":"0.0029621","valid_until_block":1200,"attributes":[],"cosigners":[],"vin":[],"vout":[],"scripts":[{"invocation":"0c40b192490537d5ec2c747fdf6ad8d73d0e3aae105c3d9ed96e7e032b28018fa54996661b17aaa107adc7a73a8ca3916b61a4b2b673e1b2a30c3c7117a01cf937a1","verification":"0c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20b410a906ad4"}],"script":"10c00c04696e69740c14769162241eedf97c2481652adf1ba0f5bf57431b41627d5b52"},{"txid":"0xd3c3104eb1c059985ddeacc3a149634c830b39cf3fa37f4a2f7af0e4980ff370","size":269,"type":"InvocationTransaction","version":1,"nonce":9,"sender":"ALHF9wsXZVEuCGgmDA6ZNsCLtrb4A1g4yG","sys_fee":"0","net_fee":"0.0036921","valid_until_block":1200,"attributes":[],"cosigners":[{"account":"0x870958fd19ee3f6c7dc3c2df399d013910856e31","scopes":1}],"vin":[],"vout":[],"scripts":[{"invocation":"0c40cf193534761a987324a355749f5e4ef8499ff5948df6ee8a4b9834cbe025103ad08a74a00e1e248c73f3d967b23d09af0d200d9cb742ec0aa911f7f783cbd2e0","verification":"0c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20b410a906ad4"}],"script":"01e8030c14316e851039019d39dfc2c37d6c3fee19fd5809870c14769162241eedf97c2481652adf1ba0f5bf57431b13c00c087472616e736665720c14769162241eedf97c2481652adf1ba0f5bf57431b41627d5b5238"}]}]}`,
|
||||
`{"jsonrpc":"2.0","method":"transaction_added","params":[{"txid":"0xe1e0200a69f3096010c75dd003653e5bd945e414d0b0a3b95e3dfe291534c8e5","size":267,"version":0,"nonce":9,"sender":"ALHF9wsXZVEuCGgmDA6ZNsCLtrb4A1g4yG","sys_fee":"0","net_fee":"0.0036721","valid_until_block":1200,"attributes":[],"cosigners":[{"account":"0x870958fd19ee3f6c7dc3c2df399d013910856e31","scopes":1}],"script":"007b0c1420728274afafc36f43a071d328cfa3e629d9cbb00c14316e851039019d39dfc2c37d6c3fee19fd58098713c00c087472616e736665720c14769162241eedf97c2481652adf1ba0f5bf57431b41627d5b5238","vin":[],"vout":[],"scripts":[{"invocation":"0c40b61d89290451852143490194e09a547d79b8b6cda05691c085160cc0ddebc6e3a508defae7ac04e015c85af6b6fcb487a954c2a884d4cc147c9959f776844b3c","verification":"0c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20b410a906ad4"}]}]}`,
|
||||
`{"jsonrpc":"2.0","method":"block_added","params":[{"hash":"0x73f4157bc918f0af115522380b13dadf505773f91e818288edb0de4fcce104b4","version":0,"previousblockhash":"0x3c664cf156f2f418e92fd24621ac3b56da4a4c1e56c443fe360d52324d8f060f","merkleroot":"0xfa9e8e7a506c1a38fa1f090237156debd055c8cf41d743ae4f37fe3c278ff2e0","time":1591360099006,"index":6,"nextconsensus":"AXSvJVzydxXuL9da4GVwK25zdesCrVKkHL","witnesses":[{"invocation":"0c40d7690b2335898b192d408f3565fb8da0f994a305999f1b7b87000934831f76d680442ea2c44200c2b154c12a0ee587046eeec45f749b73ce3bc97ac172487f350c400835fd349d184a691087b24a827d82bad3026ffa0e7f2841e85fb91f5c9549e6a1430883586cbbfba3a450a0198608e19c0b1630677bbd9495e3f48c8c4835c40c400fd2d4dfee36f99de6df35b1c857eb7c8b9b26574a781114081b066b806a1bcae129d05329298b0e6b4728da90928d4a375157dd7472fb37351a20d1a84996790c404b58d5f6374bf6c2ab12f51e6f78a07852e027279879a5fb25b5e6371ad9d89749127e7b8f8eae3df45bfe187ae226aa1aeead061006da7c4e665d97950c9a3e","verification":"130c2102103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e0c2102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd620c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20c2103d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699140b413073b3bb"}],"consensus_data":{"primary":0,"nonce":"0000000000000457"},"tx":[{"txid":"0xe1e0200a69f3096010c75dd003653e5bd945e414d0b0a3b95e3dfe291534c8e5","size":267,"version":0,"nonce":9,"sender":"ALHF9wsXZVEuCGgmDA6ZNsCLtrb4A1g4yG","sys_fee":"0","net_fee":"0.0036721","valid_until_block":1200,"attributes":[],"cosigners":[{"account":"0x870958fd19ee3f6c7dc3c2df399d013910856e31","scopes":1}],"script":"007b0c1420728274afafc36f43a071d328cfa3e629d9cbb00c14316e851039019d39dfc2c37d6c3fee19fd58098713c00c087472616e736665720c14769162241eedf97c2481652adf1ba0f5bf57431b41627d5b5238","vin":[],"vout":[],"scripts":[{"invocation":"0c40b61d89290451852143490194e09a547d79b8b6cda05691c085160cc0ddebc6e3a508defae7ac04e015c85af6b6fcb487a954c2a884d4cc147c9959f776844b3c","verification":"0c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20b410a906ad4"}]}]}]}`,
|
||||
`{"jsonrpc":"2.0","method":"event_missed","params":[]}`,
|
||||
}
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
||||
|
|
|
@ -496,13 +496,7 @@ func (s *Server) getApplicationLog(reqParams request.Params) (interface{}, *resp
|
|||
return nil, response.NewRPCError("Error while getting transaction", "", nil)
|
||||
}
|
||||
|
||||
var scriptHash util.Uint160
|
||||
switch t := tx.Data.(type) {
|
||||
case *transaction.InvocationTX:
|
||||
scriptHash = hash.Hash160(t.Script)
|
||||
default:
|
||||
return nil, response.NewRPCError("Invalid transaction type", "", nil)
|
||||
}
|
||||
scriptHash := hash.Hash160(tx.Script)
|
||||
|
||||
return result.NewApplicationLog(appExecResult, scriptHash), nil
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import (
|
|||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
||||
"github.com/nspcc-dev/neo-go/pkg/internal/testchain"
|
||||
"github.com/nspcc-dev/neo-go/pkg/internal/testserdes"
|
||||
"github.com/nspcc-dev/neo-go/pkg/io"
|
||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response"
|
||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response/result"
|
||||
|
@ -54,12 +55,12 @@ var rpcTestCases = map[string][]rpcTestCase{
|
|||
"getapplicationlog": {
|
||||
{
|
||||
name: "positive",
|
||||
params: `["70c9d7804dd19bb8d60740824d45055d117a4c51559de1b51aed0a6a127b353c"]`,
|
||||
params: `["2a6bf372fb96d05735eeb685805396818ac3f21e748528f4d6ebdecfd07ddce4"]`,
|
||||
result: func(e *executor) interface{} { return &result.ApplicationLog{} },
|
||||
check: func(t *testing.T, e *executor, acc interface{}) {
|
||||
res, ok := acc.(*result.ApplicationLog)
|
||||
require.True(t, ok)
|
||||
expectedTxHash, err := util.Uint256DecodeStringLE("70c9d7804dd19bb8d60740824d45055d117a4c51559de1b51aed0a6a127b353c")
|
||||
expectedTxHash, err := util.Uint256DecodeStringLE("2a6bf372fb96d05735eeb685805396818ac3f21e748528f4d6ebdecfd07ddce4")
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, expectedTxHash, res.TxHash)
|
||||
assert.Equal(t, 1, len(res.Executions))
|
||||
|
@ -82,11 +83,6 @@ var rpcTestCases = map[string][]rpcTestCase{
|
|||
params: `["d24cc1d52b5c0216cbf3835bb5bac8ccf32639fa1ab6627ec4e2b9f33f7ec02f"]`,
|
||||
fail: true,
|
||||
},
|
||||
{
|
||||
name: "invalid tx type",
|
||||
params: `["f9adfde059810f37b3d0686d67f6b29034e0c669537df7e59b40c14a0508b9ed"]`,
|
||||
fail: true,
|
||||
},
|
||||
},
|
||||
"getcontractstate": {
|
||||
{
|
||||
|
@ -333,7 +329,6 @@ var rpcTestCases = map[string][]rpcTestCase{
|
|||
for i, tx := range res.Transactions {
|
||||
actualTx := block.Transactions[i]
|
||||
require.True(t, ok)
|
||||
require.Equal(t, actualTx.Type, tx.Type)
|
||||
require.Equal(t, actualTx.Nonce, tx.Nonce)
|
||||
require.Equal(t, block.Transactions[i].Hash(), tx.Hash())
|
||||
}
|
||||
|
@ -489,7 +484,7 @@ var rpcTestCases = map[string][]rpcTestCase{
|
|||
"gettransactionheight": {
|
||||
{
|
||||
name: "positive",
|
||||
params: `["70c9d7804dd19bb8d60740824d45055d117a4c51559de1b51aed0a6a127b353c"]`,
|
||||
params: `["2a6bf372fb96d05735eeb685805396818ac3f21e748528f4d6ebdecfd07ddce4"]`,
|
||||
result: func(e *executor) interface{} {
|
||||
h := 0
|
||||
return &h
|
||||
|
@ -683,7 +678,7 @@ var rpcTestCases = map[string][]rpcTestCase{
|
|||
"sendrawtransaction": {
|
||||
{
|
||||
name: "positive",
|
||||
params: `["d1010a000000316e851039019d39dfc2c37d6c3fee19fd5809870000000000000000aab9050000000000b00400005d0300e87648170000000c1420728274afafc36f43a071d328cfa3e629d9cbb00c14316e851039019d39dfc2c37d6c3fee19fd58098713c00c087472616e736665720c14897720d8cd76f4f00abfa37c0edd889c208fde9b41627d5b52380001316e851039019d39dfc2c37d6c3fee19fd58098701000001420c40fadd2f9ddbe9484ef3577f131b0dec21b46a0d1c2fedd498ec258e378683d35d7159fd21120d832c1bff891c36bd765b50546ac762db4f4735f2df23ba2ec84a290c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20b410a906ad4"]`,
|
||||
params: `["000a000000316e851039019d39dfc2c37d6c3fee19fd5809870000000000000000c2b5050000000000b00400000001316e851039019d39dfc2c37d6c3fee19fd580987015d0300e87648170000000c1420728274afafc36f43a071d328cfa3e629d9cbb00c14316e851039019d39dfc2c37d6c3fee19fd58098713c00c087472616e736665720c14897720d8cd76f4f00abfa37c0edd889c208fde9b41627d5b5238000001420c4070b2b74b193b574fede47432a9bfa192726603a7f1ef6f6589f192943eb5978f47d25a7834ae7f42a0ebf4e013d1d1c2d1bb61417890335e9804ef26a94d2c00290c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20b410a906ad4"]`,
|
||||
result: func(e *executor) interface{} {
|
||||
v := true
|
||||
return &v
|
||||
|
@ -691,7 +686,7 @@ var rpcTestCases = map[string][]rpcTestCase{
|
|||
},
|
||||
{
|
||||
name: "negative",
|
||||
params: `["d1010a000000316e851039019d39dfc2c37d6c3fee19fd5809870000000000000000aab9050000000000b00400005d0300e87648170000000c1420728274afafc36f43a071d328cfa3e629d9cbb00c14316e851039019d39dfc2c37d6c3fee19fd58098713c00c087472616e736665720c14897720d8cd76f4f00abfa37c0edd889c208fde9b41627d5b52380001316e851039019d39dfc2c37d6c3fee19fd58098701000001420c40fadd2f9ddbe9484ef3577f131b0dec21b46a0d1c2fedd498ec258e378683d35d7159fd21120d832c1bff891c36bd765b50546ac762db4f4735f2df23ba2ec84a290c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20b410a906ad5"]`,
|
||||
params: `["000a000000316e851039019d39dfc2c37d6c3fee19fd5809870000000000000000c2b5050000000000b00400000001316e851039019d39dfc2c37d6c3fee19fd580987015d0300e87648170000000c1420728274afafc36f43a071d328cfa3e629d9cbb00c14316e851039019d39dfc2c37d6c3fee19fd58098713c00c087472616e736665720c14897720d8cd76f4f00abfa37c0edd889c208fde9b41627d5b5238000001420c4070b2b74b193b574fede47432a9bfa192726603a7f1ef6f6589f192943eb5978f47d25a7834ae7f42a0ebf4e013d1d1c2d1bb61417890335e9804ef26a94d2c00290c2102b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc20b410a906aff"]`,
|
||||
fail: true,
|
||||
},
|
||||
{
|
||||
|
@ -821,7 +816,7 @@ func testRPCProtocol(t *testing.T, doRPCCall func(string, string, *testing.T) []
|
|||
|
||||
newTx := func() *transaction.Transaction {
|
||||
height := chain.BlockHeight()
|
||||
tx := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx := transaction.New([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx.Nonce = height + 1
|
||||
tx.ValidUntilBlock = height + 10
|
||||
tx.Sender = acc0.PrivateKey().GetScriptHash()
|
||||
|
@ -848,26 +843,32 @@ func testRPCProtocol(t *testing.T, doRPCCall func(string, string, *testing.T) []
|
|||
|
||||
t.Run("getrawtransaction", func(t *testing.T) {
|
||||
block, _ := chain.GetBlock(chain.GetHeaderHash(0))
|
||||
TXHash := block.Transactions[0].Hash()
|
||||
rpc := fmt.Sprintf(`{"jsonrpc": "2.0", "id": 1, "method": "getrawtransaction", "params": ["%s"]}"`, TXHash.StringLE())
|
||||
tx := block.Transactions[0]
|
||||
rpc := fmt.Sprintf(`{"jsonrpc": "2.0", "id": 1, "method": "getrawtransaction", "params": ["%s"]}"`, tx.Hash().StringLE())
|
||||
body := doRPCCall(rpc, httpSrv.URL, t)
|
||||
result := checkErrGetResult(t, body, false)
|
||||
var res string
|
||||
err := json.Unmarshal(result, &res)
|
||||
require.NoErrorf(t, err, "could not parse response: %s", result)
|
||||
assert.Equal(t, "d10100000000ca61e52e881d41374e640f819cd118cc153b21a700000000000000000000000000000000000000000541123e7fe80000000001000111", res)
|
||||
txBin, err := testserdes.EncodeBinary(tx)
|
||||
require.NoError(t, err)
|
||||
expected := hex.EncodeToString(txBin)
|
||||
assert.Equal(t, expected, res)
|
||||
})
|
||||
|
||||
t.Run("getrawtransaction 2 arguments", func(t *testing.T) {
|
||||
block, _ := chain.GetBlock(chain.GetHeaderHash(0))
|
||||
TXHash := block.Transactions[0].Hash()
|
||||
rpc := fmt.Sprintf(`{"jsonrpc": "2.0", "id": 1, "method": "getrawtransaction", "params": ["%s", 0]}"`, TXHash.StringLE())
|
||||
tx := block.Transactions[0]
|
||||
rpc := fmt.Sprintf(`{"jsonrpc": "2.0", "id": 1, "method": "getrawtransaction", "params": ["%s", 0]}"`, tx.Hash().StringLE())
|
||||
body := doRPCCall(rpc, httpSrv.URL, t)
|
||||
result := checkErrGetResult(t, body, false)
|
||||
var res string
|
||||
err := json.Unmarshal(result, &res)
|
||||
require.NoErrorf(t, err, "could not parse response: %s", result)
|
||||
assert.Equal(t, "d10100000000ca61e52e881d41374e640f819cd118cc153b21a700000000000000000000000000000000000000000541123e7fe80000000001000111", res)
|
||||
txBin, err := testserdes.EncodeBinary(tx)
|
||||
require.NoError(t, err)
|
||||
expected := hex.EncodeToString(txBin)
|
||||
assert.Equal(t, expected, res)
|
||||
})
|
||||
|
||||
t.Run("getrawtransaction 2 arguments, verbose", func(t *testing.T) {
|
||||
|
@ -945,7 +946,7 @@ func testRPCProtocol(t *testing.T, doRPCCall func(string, string, *testing.T) []
|
|||
expected = append(expected, tx.Tx.Hash())
|
||||
}
|
||||
for i := 0; i < 5; i++ {
|
||||
tx := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx := transaction.New([]byte{byte(opcode.PUSH1)}, 0)
|
||||
assert.NoError(t, mp.Add(tx, &FeerStub{}))
|
||||
expected = append(expected, tx.Hash())
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import (
|
|||
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
||||
"github.com/nspcc-dev/neo-go/pkg/internal/testchain"
|
||||
"github.com/nspcc-dev/neo-go/pkg/rpc/response"
|
||||
|
@ -98,17 +97,12 @@ func TestSubscriptions(t *testing.T) {
|
|||
|
||||
for _, b := range getTestBlocks(t) {
|
||||
require.NoError(t, chain.AddBlock(b))
|
||||
for _, tx := range b.Transactions {
|
||||
var mayNotify bool
|
||||
|
||||
if tx.Type == transaction.InvocationType {
|
||||
resp := getNotification(t, respMsgs)
|
||||
require.Equal(t, response.ExecutionEventID, resp.Event)
|
||||
mayNotify = true
|
||||
}
|
||||
for range b.Transactions {
|
||||
resp := getNotification(t, respMsgs)
|
||||
require.Equal(t, response.ExecutionEventID, resp.Event)
|
||||
for {
|
||||
resp := getNotification(t, respMsgs)
|
||||
if mayNotify && resp.Event == response.NotificationEventID {
|
||||
if resp.Event == response.NotificationEventID {
|
||||
continue
|
||||
}
|
||||
require.Equal(t, response.TransactionEventID, resp.Event)
|
||||
|
|
BIN
pkg/rpc/server/testdata/testblocks.acc
vendored
BIN
pkg/rpc/server/testdata/testblocks.acc
vendored
Binary file not shown.
|
@ -165,7 +165,7 @@ func newParam(typ smartcontract.ParamType, name string) wallet.ContractParam {
|
|||
}
|
||||
|
||||
func getContractTx() *transaction.Transaction {
|
||||
tx := transaction.NewInvocationTX([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx := transaction.New([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx.AddInput(&transaction.Input{
|
||||
PrevHash: util.Uint256{1, 2, 3, 4},
|
||||
PrevIndex: 5,
|
||||
|
|
Loading…
Reference in a new issue