Skip to content

Commit

Permalink
fixup: Respond to review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
marun committed May 30, 2024
1 parent 184bbe6 commit 9533df1
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 32 deletions.
54 changes: 31 additions & 23 deletions tests/antithesis/avalanchego/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -522,54 +522,62 @@ func (w *workload) makeOwner() secp256k1fx.OutputOwners {

func (w *workload) confirmXChainTx(ctx context.Context, tx *xtxs.Tx) {
txID := tx.ID()
confirmed := true
for _, uri := range w.uris {
client := avm.NewClient(uri, "X")
status, err := client.ConfirmTx(ctx, txID, 100*time.Millisecond)
if err != nil {
log.Printf("failed to confirm X-chain transaction %s on %s: %s", txID, uri, err)
confirmed = false
break
assert.Unreachable("failed to determine the status of an X-chain transaction", map[string]any{
"worker": w.id,
"txid": txID,
"uri": uri,
"err": err,
})
return
}
if status != choices.Accepted {
log.Printf("failed to confirm X-chain transaction %s on %s: status == %s", txID, uri, status)
confirmed = false
break
assert.Unreachable("failed to confirm an X-chain transaction", map[string]any{
"worker": w.id,
"txid": txID,
"uri": uri,
"status": status,
})
return
}
log.Printf("confirmed X-chain transaction %s on %s", txID, uri)
}
if confirmed {
log.Printf("confirmed X-chain transaction %s on all nodes", txID)
}
assert.Always(confirmed, "X-chain transactions can be confirmed on all nodes", map[string]any{
"txID": txID,
})
log.Printf("confirmed X-chain transaction %s on all nodes", txID)
}

func (w *workload) confirmPChainTx(ctx context.Context, tx *ptxs.Tx) {
txID := tx.ID()
confirmed := true
for _, uri := range w.uris {
client := platformvm.NewClient(uri)
s, err := client.AwaitTxDecided(ctx, txID, 100*time.Millisecond)
if err != nil {
log.Printf("failed to confirm P-chain transaction %s on %s: %s", txID, uri, err)
confirmed = false
break
log.Printf("failed to determine the status of a P-chain transaction %s on %s: %s", txID, uri, err)
assert.Unreachable("failed to determine the status of a P-chain transaction", map[string]any{
"worker": w.id,
"txid": txID,
"uri": uri,
"err": err,
})
return
}
if s.Status != status.Committed {
log.Printf("failed to confirm P-chain transaction %s on %s: status == %s", txID, uri, s.Status)
confirmed = false
break
assert.Unreachable("failed to confirm a P-chain transaction", map[string]any{
"worker": w.id,
"txid": txID,
"uri": uri,
"status": s.Status,
})
return
}
log.Printf("confirmed P-chain transaction %s on %s", txID, uri)
}
if confirmed {
log.Printf("confirmed P-chain transaction %s on all nodes", txID)
}
assert.Always(confirmed, "P-chain transactions can be confirmed on all nodes", map[string]any{
"txID": txID,
})
log.Printf("confirmed P-chain transaction %s on all nodes", txID)
}

func (w *workload) verifyXChainTxConsumedUTXOs(ctx context.Context, tx *xtxs.Tx) {
Expand Down
17 changes: 8 additions & 9 deletions tests/antithesis/xsvm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,19 +165,18 @@ func (w *workload) run(ctx context.Context) {
}

func (w *workload) confirmTransferTx(ctx context.Context, tx *status.TxIssuance) {
confirmed := true
for _, uri := range w.uris {
client := api.NewClient(uri, w.chainID.String())
if err := api.WaitForAcceptance(ctx, client, w.key.Address(), tx.Nonce); err != nil {
log.Printf("worker %d failed to confirm transaction %s on %s: %s", w.id, tx.TxID, uri, err)
confirmed = false
break
assert.Unreachable("failed to confirm transaction", map[string]any{
"worker": w.id,
"txid": tx.TxID,
"uri": uri,
"err": err,
})
return
}
}
if confirmed {
log.Printf("worker %d confirmed transaction %s on all nodes", w.id, tx.TxID)
}
assert.Always(confirmed, "Transactions can be confirmed on all nodes", map[string]any{
"txID": tx.TxID,
})
log.Printf("worker %d confirmed transaction %s on all nodes", w.id, tx.TxID)
}

0 comments on commit 9533df1

Please sign in to comment.