Skip to content

Commit 146008a

Browse files
committed
per issue not per block
1 parent 7522e88 commit 146008a

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

testutil/random_network/config.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@ type FuzzConfig struct {
1313
// The probability that a transaction verification will fail. Default is .1%.
1414
TxVerificationFailure float64
1515

16-
// The minimum and maximum number of transactions per block. Default is between 5 and 20.
17-
MinTxsPerBlock int
18-
MaxTxsPerBlock int
16+
// The minimum and maximum number of transactions to be issued at a block. Default is between 5 and 20.
17+
MinTxsPerIssue int
18+
MaxTxsPerIssue int
19+
20+
// Number of transactions per block. Default is 15.
21+
TxsPerBlock int
1922

2023
// The number of blocks that must be finalized before ending the fuzz test. Default is 100.
2124
NumFinalizedBlocks int
@@ -42,8 +45,9 @@ func DefaultFuzzConfig() *FuzzConfig {
4245
MinNodes: 3,
4346
MaxNodes: 10,
4447
TxVerificationFailure: .001,
45-
MinTxsPerBlock: 5,
46-
MaxTxsPerBlock: 20,
48+
MinTxsPerIssue: 5,
49+
MaxTxsPerIssue: 20,
50+
TxsPerBlock: 15,
4751
NumFinalizedBlocks: 100,
4852
RandomSeed: time.Now().UnixMilli(),
4953
NodeCrashPercentage: 0.1,

testutil/random_network/mempool.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ func (m *Mempool) BuildBlock(ctx context.Context, md simplex.ProtocolMetadata, b
197197
m.WaitForPendingTxs(ctx)
198198

199199
// Pack the block once we have pending txs
200-
txs := m.PackBlock(ctx, m.config.MaxTxsPerBlock)
200+
txs := m.PackBlock(ctx, m.config.TxsPerBlock)
201201
if ctx.Err() != nil {
202202
return nil, false
203203
}

testutil/random_network/network.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func (n *Network) Run() {
8888
n.recoverToHeight(n.getMaxHeight())
8989
maxHeight := n.getMaxHeight()
9090
minHeight := n.getMinHeight()
91-
91+
9292
n.logger.Info("Issued Transactions", zap.Int("count", len(txs)), zap.Uint64("min height", minHeight), zap.Uint64("max height", maxHeight))
9393
if prevHeight == int(maxHeight) {
9494
panic(fmt.Sprintf(
@@ -141,7 +141,6 @@ func (n *Network) recoverToHeight(height uint64) {
141141
}
142142
}
143143

144-
145144
n.lock.Lock()
146145
n.BasicInMemoryNetwork.AdvanceTime(n.config.AdvanceTimeTickAmount)
147146
n.lock.Unlock()
@@ -153,7 +152,7 @@ func (n *Network) IssueTxs() []*TX {
153152
n.lock.Lock()
154153
defer n.lock.Unlock()
155154

156-
numTxs := n.randomness.Intn(n.config.MaxTxsPerBlock-n.config.MinTxsPerBlock+1) + n.config.MinTxsPerBlock // randomize between min and max inclusive
155+
numTxs := n.randomness.Intn(n.config.MaxTxsPerIssue-n.config.MinTxsPerIssue+1) + n.config.MinTxsPerIssue // randomize between min and max inclusive
157156
txs := make([]*TX, 0, numTxs)
158157

159158
for range numTxs {

0 commit comments

Comments
 (0)