Skip to content

Commit

Permalink
Many transactions unit test
Browse files Browse the repository at this point in the history
This is a network unit test which keeps increasing the number of
transactions sent to be externalized. This is to test the gossiping and
consensus protocol implementation works with large numbers of
transactions.
  • Loading branch information
hewison-chris committed Dec 21, 2021
1 parent 1b6c125 commit 46709f7
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions source/agora/test/ManyTransactions.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*******************************************************************************
Each block send double the txs
Run via:
$ dtest=agora.test.ManyTransactions dub test
Copyright:
Copyright (c) 2019-2021 BOSAGORA Foundation
All rights reserved.
License:
MIT License. See LICENSE for details.
*******************************************************************************/

module agora.test.ManyTransactions;

version (unittest):

import agora.test.Base;
import agora.utils.Log;
import agora.utils.PrettyPrinter;

mixin AddLogger!();

unittest
{
TestConf conf;
conf.consensus.quorum_threshold = 100;
auto network = makeTestNetwork!TestAPIManager(conf);
network.start();
scope(exit) network.shutdown();
scope(failure) network.printLogs();
network.waitForDiscovery();

auto nodes = network.clients;
auto node_1 = nodes[0];

const txsInBlockTarget = 32;
ulong posted_txs = 8; // From Genesis
while (posted_txs < txsInBlockTarget)
{
auto last_block = node_1.getBlock(node_1.getBlockHeight());
auto txs = last_block.spendable().map!(txb => txb.split(WK.Keys.byRange.take(2).map!(kp => kp.address)).sign());
txs.each!(tx => node_1.postTransaction(tx));
posted_txs = txs.walkLength;
log.info("Sent {} TXs", posted_txs);
network.expectHeight(Height(node_1.getBlockHeight() + 1), 10.seconds);
}
}

0 comments on commit 46709f7

Please sign in to comment.