Skip to content
Permalink
Browse files

Add regression test

  • Loading branch information
moreal committed Feb 11, 2020
1 parent 3ef66e3 commit 27203149081b4bce9d0f4bd5e3a0572e3597e8c4
Showing with 25 additions and 0 deletions.
  1. +25 −0 Libplanet.Tests/Blockchain/BlockChainTest.cs
@@ -2063,6 +2063,31 @@ private void ConstructWithUnexpectedGenesisBlock()
});
}

[Fact]
private async Task IgnoreLowerNonceTxsAndMine()
{
var privateKey = new PrivateKey();
var address = privateKey.PublicKey.ToAddress();
var txsA = Enumerable.Range(0, 3)
.Select(nonce => _fx.MakeTransaction(
nonce: nonce, privateKey: privateKey, timestamp: DateTimeOffset.Now))
.ToArray();
_blockChain.StageTransactions(txsA.ToImmutableHashSet());
Block<DumbAction> b1 = await _blockChain.MineBlock(address);
Assert.Equal(txsA, b1.Transactions);

var txsB = Enumerable.Range(0, 4)
.Select(nonce => _fx.MakeTransaction(
nonce: nonce, privateKey: privateKey, timestamp: DateTimeOffset.Now))
.ToArray();
_blockChain.StageTransactions(txsB.ToImmutableHashSet());

// Mine only txs having higher or equal with nonce than expected nonce.
Block<DumbAction> b2 = await _blockChain.MineBlock(address);
Assert.Single(b2.Transactions);
Assert.Contains(txsB[3], b2.Transactions);
}

private sealed class TestEvaluateAction : IAction
{
public static readonly Address SignerKey =

0 comments on commit 2720314

Please sign in to comment.
You can’t perform that action at this time.