Skip to content

Commit

Permalink
Adds bundle tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
ckartik committed Jan 22, 2024
1 parent 5b8a8e8 commit 1e0bca3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/updater/updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ func (u *Updater) Start(ctx context.Context) <-chan struct{} {
for i := 0; i < len(commitmentTxnHashes) && ok; i++ {
if newPos, found := txnsInBlock[commitmentTxnHashes[i]]; !found || newPos != txnsInBlock[commitmentTxnHashes[0]]+i {
ok = false
break
}
}

err = u.winnerRegister.AddSettlement(
ctx,
index[:],
Expand Down
18 changes: 17 additions & 1 deletion pkg/updater/updater_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,28 @@ func TestUpdater(t *testing.T) {
commitments := make(map[string]preconf.PreConfCommitmentStorePreConfCommitment)
for i, txn := range txns {
idxBytes := getIdxBytes(int64(i))

commitments[string(idxBytes[:])] = preconf.PreConfCommitmentStorePreConfCommitment{
Commiter: builderAddr,
TxnHash: txn.Hash().Hex(),
}
}

// constructing bundles
for i := 0; i < 10; i++ {
idxBytes := getIdxBytes(int64(i + 10))

bundle := txns[i].Hash().Hex()
for j := i + 1; j < 10; j++ {
bundle += "," + txns[j].Hash().Hex()
}

commitments[string(idxBytes[:])] = preconf.PreConfCommitmentStorePreConfCommitment{
Commiter: builderAddr,
TxnHash: bundle,
}
}

testWinnerRegister := &testWinnerRegister{
winners: make(chan updater.BlockWinner),
settlements: make(chan testSettlement),
Expand Down Expand Up @@ -117,7 +133,7 @@ func TestUpdater(t *testing.T) {

count := 0
for {
if count == 10 {
if count == 20 {
break
}
settlement := <-testWinnerRegister.settlements
Expand Down

0 comments on commit 1e0bca3

Please sign in to comment.