-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
1 parent
6e3a0e7
commit 0570195
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/******************************************************************************* | ||
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.consensus.data.genesis.Test; | ||
import agora.test.Base; | ||
import agora.utils.Log; | ||
import agora.utils.PrettyPrinter; | ||
|
||
mixin AddLogger!(); | ||
|
||
unittest | ||
{ | ||
TestConf conf; | ||
conf.node.test_validators = 4; | ||
conf.node.retry_delay = 1.msecs; | ||
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 = 100; | ||
Block last_block = cast(Block) node_1.getAllBlocks()[0]; | ||
ulong txs_last_block = 8; // From Genesis | ||
while (txs_last_block < txsInBlockTarget) | ||
{ | ||
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)); | ||
network.expectHeight(Height(node_1.getBlockHeight() + 1), 10.seconds); | ||
last_block = cast(Block) node_1.getBlock(node_1.getBlockHeight()); | ||
txs_last_block = last_block.txs.walkLength; | ||
log.info("{} TXs in block {}", txs_last_block, last_block.header.height); | ||
} | ||
} |