mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-03 01:41:48 +00:00
transaction: drop Network from Transaction
We only need it when signing/verifying.
This commit is contained in:
parent
df12adaa9e
commit
d314f82db3
54 changed files with 305 additions and 373 deletions
|
@ -1076,7 +1076,6 @@ func TestSubmitNotaryRequest(t *testing.T) {
|
|||
t.Run("invalid request bytes", runCase(t, true, `"not-a-request"`))
|
||||
t.Run("invalid request", func(t *testing.T) {
|
||||
mainTx := &transaction.Transaction{
|
||||
Network: netmode.UnitTestNet,
|
||||
Attributes: []transaction.Attribute{{Type: transaction.NotaryAssistedT, Value: &transaction.NotaryAssisted{NKeys: 1}}},
|
||||
Script: []byte{byte(opcode.RET)},
|
||||
ValidUntilBlock: 123,
|
||||
|
@ -1087,7 +1086,6 @@ func TestSubmitNotaryRequest(t *testing.T) {
|
|||
}},
|
||||
}
|
||||
fallbackTx := &transaction.Transaction{
|
||||
Network: netmode.UnitTestNet,
|
||||
Script: []byte{byte(opcode.RET)},
|
||||
ValidUntilBlock: 123,
|
||||
Attributes: []transaction.Attribute{
|
||||
|
@ -1117,7 +1115,6 @@ func TestSubmitNotaryRequest(t *testing.T) {
|
|||
t.Run("valid request", func(t *testing.T) {
|
||||
sender := testchain.PrivateKeyByID(0) // owner of the deposit in testchain
|
||||
mainTx := &transaction.Transaction{
|
||||
Network: netmode.UnitTestNet,
|
||||
Attributes: []transaction.Attribute{{Type: transaction.NotaryAssistedT, Value: &transaction.NotaryAssisted{NKeys: 1}}},
|
||||
Script: []byte{byte(opcode.RET)},
|
||||
ValidUntilBlock: 123,
|
||||
|
@ -1128,7 +1125,6 @@ func TestSubmitNotaryRequest(t *testing.T) {
|
|||
}},
|
||||
}
|
||||
fallbackTx := &transaction.Transaction{
|
||||
Network: netmode.UnitTestNet,
|
||||
Script: []byte{byte(opcode.RET)},
|
||||
ValidUntilBlock: 123,
|
||||
Attributes: []transaction.Attribute{
|
||||
|
@ -1143,7 +1139,7 @@ func TestSubmitNotaryRequest(t *testing.T) {
|
|||
NetworkFee: 2_0000_0000,
|
||||
}
|
||||
fallbackTx.Scripts = append(fallbackTx.Scripts, transaction.Witness{
|
||||
InvocationScript: append([]byte{byte(opcode.PUSHDATA1), 64}, sender.Sign(fallbackTx.GetSignedPart())...),
|
||||
InvocationScript: append([]byte{byte(opcode.PUSHDATA1), 64}, sender.SignHashable(uint32(testchain.Network()), fallbackTx)...),
|
||||
VerificationScript: sender.PublicKey().GetVerificationScript(),
|
||||
})
|
||||
p := &payload.P2PNotaryRequest{
|
||||
|
@ -1152,7 +1148,7 @@ func TestSubmitNotaryRequest(t *testing.T) {
|
|||
FallbackTransaction: fallbackTx,
|
||||
}
|
||||
p.Witness = transaction.Witness{
|
||||
InvocationScript: append([]byte{byte(opcode.PUSHDATA1), 64}, sender.Sign(p.GetSignedPart())...),
|
||||
InvocationScript: append([]byte{byte(opcode.PUSHDATA1), 64}, sender.SignHashable(uint32(testchain.Network()), p)...),
|
||||
VerificationScript: sender.PublicKey().GetVerificationScript(),
|
||||
}
|
||||
bytes, err := p.Bytes()
|
||||
|
@ -1314,12 +1310,12 @@ func testRPCProtocol(t *testing.T, doRPCCall func(string, string, *testing.T) []
|
|||
|
||||
newTx := func() *transaction.Transaction {
|
||||
height := chain.BlockHeight()
|
||||
tx := transaction.New(testchain.Network(), []byte{byte(opcode.PUSH1)}, 0)
|
||||
tx := transaction.New([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx.Nonce = height + 1
|
||||
tx.ValidUntilBlock = height + 10
|
||||
tx.Signers = []transaction.Signer{{Account: acc0.PrivateKey().GetScriptHash()}}
|
||||
addNetworkFee(tx)
|
||||
require.NoError(t, acc0.SignTx(tx))
|
||||
require.NoError(t, acc0.SignTx(testchain.Network(), tx))
|
||||
return tx
|
||||
}
|
||||
|
||||
|
@ -1417,7 +1413,7 @@ func testRPCProtocol(t *testing.T, doRPCCall func(string, string, *testing.T) []
|
|||
rpc := fmt.Sprintf(`{"jsonrpc": "2.0", "id": 1, "method": "getrawtransaction", "params": ["%s", 1]}"`, TXHash.StringLE())
|
||||
body := doRPCCall(rpc, httpSrv.URL, t)
|
||||
txOut := checkErrGetResult(t, body, false)
|
||||
actual := result.TransactionOutputRaw{Transaction: transaction.Transaction{Network: testchain.Network()}}
|
||||
actual := result.TransactionOutputRaw{Transaction: transaction.Transaction{}}
|
||||
err := json.Unmarshal(txOut, &actual)
|
||||
require.NoErrorf(t, err, "could not parse response: %s", txOut)
|
||||
|
||||
|
@ -1486,7 +1482,7 @@ func testRPCProtocol(t *testing.T, doRPCCall func(string, string, *testing.T) []
|
|||
expected = append(expected, tx.Hash())
|
||||
}
|
||||
for i := 0; i < 5; i++ {
|
||||
tx := transaction.New(testchain.Network(), []byte{byte(opcode.PUSH1)}, 0)
|
||||
tx := transaction.New([]byte{byte(opcode.PUSH1)}, 0)
|
||||
tx.Signers = []transaction.Signer{{Account: util.Uint160{1, 2, 3}}}
|
||||
assert.NoError(t, mp.Add(tx, &FeerStub{}))
|
||||
expected = append(expected, tx.Hash())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue