transaction: forbid serializing invalid transactions
Transaction that has no data is invalid and can't be serialized, so throw an error if someone tries to.
This commit is contained in:
parent
9374c5e7c2
commit
388fed06e5
5 changed files with 25 additions and 14 deletions
|
@ -86,8 +86,8 @@ func newDumbBlock() *Block {
|
|||
},
|
||||
},
|
||||
Transactions: []*transaction.Transaction{
|
||||
{Type: transaction.MinerType},
|
||||
{Type: transaction.IssueType},
|
||||
{Type: transaction.MinerType, Data: &transaction.MinerTX{}},
|
||||
{Type: transaction.IssueType, Data: &transaction.IssueTX{}},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -105,22 +105,22 @@ func TestBlockVerify(t *testing.T) {
|
|||
assert.Nil(t, block.Verify())
|
||||
|
||||
block.Transactions = []*transaction.Transaction{
|
||||
{Type: transaction.IssueType},
|
||||
{Type: transaction.MinerType},
|
||||
{Type: transaction.IssueType, Data: &transaction.IssueTX{}},
|
||||
{Type: transaction.MinerType, Data: &transaction.MinerTX{}},
|
||||
}
|
||||
assert.NoError(t, block.RebuildMerkleRoot())
|
||||
assert.NotNil(t, block.Verify())
|
||||
|
||||
block.Transactions = []*transaction.Transaction{
|
||||
{Type: transaction.MinerType},
|
||||
{Type: transaction.MinerType},
|
||||
{Type: transaction.IssueType, Data: &transaction.IssueTX{}},
|
||||
{Type: transaction.MinerType, Data: &transaction.MinerTX{}},
|
||||
}
|
||||
assert.NoError(t, block.RebuildMerkleRoot())
|
||||
assert.NotNil(t, block.Verify())
|
||||
block.Transactions = []*transaction.Transaction{
|
||||
{Type: transaction.MinerType},
|
||||
{Type: transaction.IssueType},
|
||||
{Type: transaction.IssueType},
|
||||
{Type: transaction.MinerType, Data: &transaction.MinerTX{}},
|
||||
{Type: transaction.IssueType, Data: &transaction.IssueTX{}},
|
||||
{Type: transaction.IssueType, Data: &transaction.IssueTX{}},
|
||||
}
|
||||
assert.NotNil(t, block.Verify())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue