public void TransactionsWithDuplicateNonce() { var dupTx1 = new Transaction <Arithmetic>( nonce: 1L, signer: Tx1InBlock1.Signer, publicKey: Tx1InBlock1.PublicKey, genesisHash: GenesisHash, updatedAddresses: ImmutableHashSet <Address> .Empty.Add(Tx1InBlock1.Signer), timestamp: Tx1InBlock1.Timestamp, actions: Array.Empty <Arithmetic>(), signature: ByteUtil.ParseHex( "304502210099e580e8599acf0b26ad0a80315f2d488703ffde01e9449b4bf399593b8cc" + "e63022002feb21bf0e4d76d25d17c8c1c4fbb3dfbda986e0693f984fbb302183ab7ece1" ) ); var block = Block1.Copy(); InvalidTxNonceException e = Assert.Throws <InvalidTxNonceException>( () => block.Transactions = new[] { Tx0InBlock1, Tx1InBlock1, dupTx1 } ); Assert.Equal(dupTx1.Id, e.TxId); Assert.Equal(2L, e.ExpectedNonce); Assert.Equal(dupTx1.Nonce, e.ImproperNonce); Assert.Equal(Block1.Transactions, block.Transactions); }
public void TransactionsWithMissingNonce() { var dupTx1 = new Transaction <Arithmetic>( nonce: 3L, signer: Tx1InBlock1.Signer, publicKey: Tx1InBlock1.PublicKey, genesisHash: GenesisHash, updatedAddresses: ImmutableHashSet <Address> .Empty.Add(Tx1InBlock1.Signer), timestamp: Tx1InBlock1.Timestamp, actions: Array.Empty <Arithmetic>(), signature: ByteUtil.ParseHex( "3045022100bfdf79427028efea9449ad46fbf46d5a806694aa5bbab1a01f4c76b21acd" + "cb16022057c851a01dd74797121385ccfc81e7b33842941189154b4d46d05e891a28e3eb" ) ); var block = Block1.Copy(); InvalidTxNonceException e = Assert.Throws <InvalidTxNonceException>( () => block.Transactions = new[] { Tx0InBlock1, Tx1InBlock1, dupTx1 } ); Assert.Equal(dupTx1.Id, e.TxId); Assert.Equal(2L, e.ExpectedNonce); Assert.Equal(dupTx1.Nonce, e.ImproperNonce); Assert.Equal(Block1.Transactions, block.Transactions); }