*: simpilfy make() invocations

gosimple: S1019: should use make([]byte, 64) instead
This commit is contained in:
Roman Khimov 2021-05-12 18:32:11 +03:00
parent 07cdbb815c
commit 0178594850
4 changed files with 15 additions and 15 deletions

View file

@ -1024,7 +1024,7 @@ func TestVerifyTx(t *testing.T) {
nativeprices.NotaryVerificationPrice*bc.GetBaseExecFee() // Notary witness verification price nativeprices.NotaryVerificationPrice*bc.GetBaseExecFee() // Notary witness verification price
tx.Scripts = []transaction.Witness{ tx.Scripts = []transaction.Witness{
{ {
InvocationScript: append([]byte{byte(opcode.PUSHDATA1), 64}, make([]byte, 64, 64)...), InvocationScript: append([]byte{byte(opcode.PUSHDATA1), 64}, make([]byte, 64)...),
VerificationScript: []byte{}, VerificationScript: []byte{},
}, },
{ {
@ -1051,7 +1051,7 @@ func TestVerifyTx(t *testing.T) {
tx.NetworkFee-- // to check that NetworkFee was set correctly in getPartiallyFilledTx tx.NetworkFee-- // to check that NetworkFee was set correctly in getPartiallyFilledTx
tx.Scripts = []transaction.Witness{ tx.Scripts = []transaction.Witness{
{ {
InvocationScript: append([]byte{byte(opcode.PUSHDATA1), 64}, make([]byte, 64, 64)...), InvocationScript: append([]byte{byte(opcode.PUSHDATA1), 64}, make([]byte, 64)...),
VerificationScript: []byte{}, VerificationScript: []byte{},
}, },
{ {

View file

@ -45,21 +45,21 @@ func TestNotaryRequestIsValid(t *testing.T) {
MainTransaction: mainTx, MainTransaction: mainTx,
FallbackTransaction: &transaction.Transaction{ FallbackTransaction: &transaction.Transaction{
Signers: []transaction.Signer{{Account: random.Uint160()}, {Account: random.Uint160()}}, Signers: []transaction.Signer{{Account: random.Uint160()}, {Account: random.Uint160()}},
Scripts: []transaction.Witness{{InvocationScript: append([]byte{byte(opcode.PUSHDATA1), 65}, make([]byte, 64, 64)...)}, {}}, Scripts: []transaction.Witness{{InvocationScript: append([]byte{byte(opcode.PUSHDATA1), 65}, make([]byte, 64)...)}, {}},
}, },
}, },
"fallback tx: invalid dummy Notary witness (non-empty verification script))": { "fallback tx: invalid dummy Notary witness (non-empty verification script))": {
MainTransaction: mainTx, MainTransaction: mainTx,
FallbackTransaction: &transaction.Transaction{ FallbackTransaction: &transaction.Transaction{
Signers: []transaction.Signer{{Account: random.Uint160()}, {Account: random.Uint160()}}, Signers: []transaction.Signer{{Account: random.Uint160()}, {Account: random.Uint160()}},
Scripts: []transaction.Witness{{InvocationScript: append([]byte{byte(opcode.PUSHDATA1), 64}, make([]byte, 64, 64)...), VerificationScript: make([]byte, 1, 1)}, {}}, Scripts: []transaction.Witness{{InvocationScript: append([]byte{byte(opcode.PUSHDATA1), 64}, make([]byte, 64)...), VerificationScript: make([]byte, 1)}, {}},
}, },
}, },
"fallback tx: missing NotValidBefore attribute": { "fallback tx: missing NotValidBefore attribute": {
MainTransaction: mainTx, MainTransaction: mainTx,
FallbackTransaction: &transaction.Transaction{ FallbackTransaction: &transaction.Transaction{
Signers: []transaction.Signer{{Account: random.Uint160()}, {Account: random.Uint160()}}, Signers: []transaction.Signer{{Account: random.Uint160()}, {Account: random.Uint160()}},
Scripts: []transaction.Witness{{InvocationScript: append([]byte{byte(opcode.PUSHDATA1), 64}, make([]byte, 64, 64)...), VerificationScript: make([]byte, 0)}, {}}, Scripts: []transaction.Witness{{InvocationScript: append([]byte{byte(opcode.PUSHDATA1), 64}, make([]byte, 64)...), VerificationScript: make([]byte, 0)}, {}},
}, },
}, },
"fallback tx: invalid number of Conflicts attributes": { "fallback tx: invalid number of Conflicts attributes": {
@ -67,7 +67,7 @@ func TestNotaryRequestIsValid(t *testing.T) {
FallbackTransaction: &transaction.Transaction{ FallbackTransaction: &transaction.Transaction{
Attributes: []transaction.Attribute{{Type: transaction.NotValidBeforeT, Value: &transaction.NotValidBefore{Height: 123}}}, Attributes: []transaction.Attribute{{Type: transaction.NotValidBeforeT, Value: &transaction.NotValidBefore{Height: 123}}},
Signers: []transaction.Signer{{Account: random.Uint160()}, {Account: random.Uint160()}}, Signers: []transaction.Signer{{Account: random.Uint160()}, {Account: random.Uint160()}},
Scripts: []transaction.Witness{{InvocationScript: append([]byte{byte(opcode.PUSHDATA1), 64}, make([]byte, 64, 64)...), VerificationScript: make([]byte, 0)}, {}}, Scripts: []transaction.Witness{{InvocationScript: append([]byte{byte(opcode.PUSHDATA1), 64}, make([]byte, 64)...), VerificationScript: make([]byte, 0)}, {}},
}, },
}, },
"fallback tx: does not conflicts with main tx": { "fallback tx: does not conflicts with main tx": {
@ -78,7 +78,7 @@ func TestNotaryRequestIsValid(t *testing.T) {
{Type: transaction.ConflictsT, Value: &transaction.Conflicts{Hash: util.Uint256{}}}, {Type: transaction.ConflictsT, Value: &transaction.Conflicts{Hash: util.Uint256{}}},
}, },
Signers: []transaction.Signer{{Account: random.Uint160()}, {Account: random.Uint160()}}, Signers: []transaction.Signer{{Account: random.Uint160()}, {Account: random.Uint160()}},
Scripts: []transaction.Witness{{InvocationScript: append([]byte{byte(opcode.PUSHDATA1), 64}, make([]byte, 64, 64)...), VerificationScript: make([]byte, 0)}, {}}, Scripts: []transaction.Witness{{InvocationScript: append([]byte{byte(opcode.PUSHDATA1), 64}, make([]byte, 64)...), VerificationScript: make([]byte, 0)}, {}},
}, },
}, },
"fallback tx: missing NotaryAssisted attribute": { "fallback tx: missing NotaryAssisted attribute": {
@ -89,7 +89,7 @@ func TestNotaryRequestIsValid(t *testing.T) {
{Type: transaction.ConflictsT, Value: &transaction.Conflicts{Hash: mainTx.Hash()}}, {Type: transaction.ConflictsT, Value: &transaction.Conflicts{Hash: mainTx.Hash()}},
}, },
Signers: []transaction.Signer{{Account: random.Uint160()}, {Account: random.Uint160()}}, Signers: []transaction.Signer{{Account: random.Uint160()}, {Account: random.Uint160()}},
Scripts: []transaction.Witness{{InvocationScript: append([]byte{byte(opcode.PUSHDATA1), 64}, make([]byte, 64, 64)...), VerificationScript: make([]byte, 0)}, {}}, Scripts: []transaction.Witness{{InvocationScript: append([]byte{byte(opcode.PUSHDATA1), 64}, make([]byte, 64)...), VerificationScript: make([]byte, 0)}, {}},
}, },
}, },
"fallback tx: non-zero NKeys": { "fallback tx: non-zero NKeys": {
@ -101,7 +101,7 @@ func TestNotaryRequestIsValid(t *testing.T) {
{Type: transaction.NotaryAssistedT, Value: &transaction.NotaryAssisted{NKeys: 1}}, {Type: transaction.NotaryAssistedT, Value: &transaction.NotaryAssisted{NKeys: 1}},
}, },
Signers: []transaction.Signer{{Account: random.Uint160()}, {Account: random.Uint160()}}, Signers: []transaction.Signer{{Account: random.Uint160()}, {Account: random.Uint160()}},
Scripts: []transaction.Witness{{InvocationScript: append([]byte{byte(opcode.PUSHDATA1), 64}, make([]byte, 64, 64)...), VerificationScript: make([]byte, 0)}, {}}, Scripts: []transaction.Witness{{InvocationScript: append([]byte{byte(opcode.PUSHDATA1), 64}, make([]byte, 64)...), VerificationScript: make([]byte, 0)}, {}},
}, },
}, },
"fallback tx: ValidUntilBlock mismatch": { "fallback tx: ValidUntilBlock mismatch": {
@ -114,7 +114,7 @@ func TestNotaryRequestIsValid(t *testing.T) {
{Type: transaction.NotaryAssistedT, Value: &transaction.NotaryAssisted{NKeys: 0}}, {Type: transaction.NotaryAssistedT, Value: &transaction.NotaryAssisted{NKeys: 0}},
}, },
Signers: []transaction.Signer{{Account: random.Uint160()}, {Account: random.Uint160()}}, Signers: []transaction.Signer{{Account: random.Uint160()}, {Account: random.Uint160()}},
Scripts: []transaction.Witness{{InvocationScript: append([]byte{byte(opcode.PUSHDATA1), 64}, make([]byte, 64, 64)...), VerificationScript: make([]byte, 0)}, {}}, Scripts: []transaction.Witness{{InvocationScript: append([]byte{byte(opcode.PUSHDATA1), 64}, make([]byte, 64)...), VerificationScript: make([]byte, 0)}, {}},
}, },
}, },
} }
@ -134,7 +134,7 @@ func TestNotaryRequestIsValid(t *testing.T) {
{Type: transaction.NotaryAssistedT, Value: &transaction.NotaryAssisted{NKeys: 0}}, {Type: transaction.NotaryAssistedT, Value: &transaction.NotaryAssisted{NKeys: 0}},
}, },
Signers: []transaction.Signer{{Account: random.Uint160()}, {Account: random.Uint160()}}, Signers: []transaction.Signer{{Account: random.Uint160()}, {Account: random.Uint160()}},
Scripts: []transaction.Witness{{InvocationScript: append([]byte{byte(opcode.PUSHDATA1), 64}, make([]byte, 64, 64)...), VerificationScript: make([]byte, 0)}, {}}, Scripts: []transaction.Witness{{InvocationScript: append([]byte{byte(opcode.PUSHDATA1), 64}, make([]byte, 64)...), VerificationScript: make([]byte, 0)}, {}},
}, },
} }
require.NoError(t, p.isValid()) require.NoError(t, p.isValid())
@ -164,7 +164,7 @@ func TestNotaryRequestBytesFromBytes(t *testing.T) {
}, },
Signers: []transaction.Signer{{Account: util.Uint160{1, 4, 7}}, {Account: util.Uint160{9, 8, 7}}}, Signers: []transaction.Signer{{Account: util.Uint160{1, 4, 7}}, {Account: util.Uint160{9, 8, 7}}},
Scripts: []transaction.Witness{ Scripts: []transaction.Witness{
{InvocationScript: append([]byte{byte(opcode.PUSHDATA1), 64}, make([]byte, 64, 64)...), VerificationScript: make([]byte, 0)}, {InvocationScript: append([]byte{byte(opcode.PUSHDATA1), 64}, make([]byte, 64)...), VerificationScript: make([]byte, 0)},
{InvocationScript: []byte{1, 2, 3}, VerificationScript: []byte{1, 2, 3}}}, {InvocationScript: []byte{1, 2, 3}, VerificationScript: []byte{1, 2, 3}}},
} }
_ = fallbackTx.Hash() _ = fallbackTx.Hash()

View file

@ -535,7 +535,7 @@ func TestGetData(t *testing.T) {
{Type: transaction.NotaryAssistedT, Value: &transaction.NotaryAssisted{NKeys: 0}}, {Type: transaction.NotaryAssistedT, Value: &transaction.NotaryAssisted{NKeys: 0}},
}, },
Signers: []transaction.Signer{{Account: random.Uint160()}, {Account: random.Uint160()}}, Signers: []transaction.Signer{{Account: random.Uint160()}, {Account: random.Uint160()}},
Scripts: []transaction.Witness{{InvocationScript: append([]byte{byte(opcode.PUSHDATA1), 64}, make([]byte, 64, 64)...), VerificationScript: make([]byte, 0)}, {InvocationScript: []byte{}, VerificationScript: []byte{}}}, Scripts: []transaction.Witness{{InvocationScript: append([]byte{byte(opcode.PUSHDATA1), 64}, make([]byte, 64)...), VerificationScript: make([]byte, 0)}, {InvocationScript: []byte{}, VerificationScript: []byte{}}},
} }
fallbackTx.Size() fallbackTx.Size()
fallbackTx.Hash() fallbackTx.Hash()

View file

@ -1088,7 +1088,7 @@ func TestSubmitNotaryRequest(t *testing.T) {
}, },
Signers: []transaction.Signer{{Account: util.Uint160{1, 4, 7}}, {Account: util.Uint160{9, 8, 7}}}, Signers: []transaction.Signer{{Account: util.Uint160{1, 4, 7}}, {Account: util.Uint160{9, 8, 7}}},
Scripts: []transaction.Witness{ Scripts: []transaction.Witness{
{InvocationScript: append([]byte{byte(opcode.PUSHDATA1), 64}, make([]byte, 64, 64)...), VerificationScript: make([]byte, 0)}, {InvocationScript: append([]byte{byte(opcode.PUSHDATA1), 64}, make([]byte, 64)...), VerificationScript: make([]byte, 0)},
{InvocationScript: []byte{1, 2, 3}, VerificationScript: []byte{1, 2, 3}}}, {InvocationScript: []byte{1, 2, 3}, VerificationScript: []byte{1, 2, 3}}},
} }
p := &payload.P2PNotaryRequest{ p := &payload.P2PNotaryRequest{
@ -1126,7 +1126,7 @@ func TestSubmitNotaryRequest(t *testing.T) {
}, },
Signers: []transaction.Signer{{Account: chain.GetNotaryContractScriptHash()}, {Account: sender.GetScriptHash()}}, Signers: []transaction.Signer{{Account: chain.GetNotaryContractScriptHash()}, {Account: sender.GetScriptHash()}},
Scripts: []transaction.Witness{ Scripts: []transaction.Witness{
{InvocationScript: append([]byte{byte(opcode.PUSHDATA1), 64}, make([]byte, 64, 64)...), VerificationScript: []byte{}}, {InvocationScript: append([]byte{byte(opcode.PUSHDATA1), 64}, make([]byte, 64)...), VerificationScript: []byte{}},
}, },
NetworkFee: 2_0000_0000, NetworkFee: 2_0000_0000,
} }