Skip to content

Commit 4a1ee21

Browse files
authored
test: accept testing.T instead of assert.Assertion (#1656)
<!-- Please read and fill out this form before submitting your PR. Please make sure you have reviewed our contributors guide before submitting your first PR. NOTE: PR titles should follow semantic commits: https://www.conventionalcommits.org/en/v1.0.0/ --> ## Overview Close #1320 <!-- Please provide an explanation of the PR, including the appropriate context, background, goal, and rationale. If there is an issue with this information, please provide a tl;dr and link the issue. Ex: Closes # --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Refactor** - Updated test functions for better error handling in full node testing. - Modified function signatures in full_node_test.go to use *testing.T instead of *assert.Assertions. - Updated assertion calls within verifyTransactions and verifyMempoolSize functions. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 1c49f34 commit 4a1ee21

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

node/full_node_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,9 @@ func TestMempoolDirectly(t *testing.T) {
4949
require.IsType(t, new(FullNode), fn)
5050

5151
node := fn.(*FullNode)
52-
assert := assert.New(t)
53-
peerID := getPeerID(assert)
54-
verifyTransactions(node, peerID, assert)
55-
verifyMempoolSize(node, assert)
52+
peerID := getPeerID(t)
53+
verifyTransactions(node, peerID, t)
54+
verifyMempoolSize(node, t)
5655
}
5756

5857
// Tests that the node is able to sync multiple blocks even if blocks arrive out of order
@@ -325,28 +324,29 @@ func generateSingleKey() crypto.PrivKey {
325324
}
326325

327326
// getPeerID generates a peer ID
328-
func getPeerID(assert *assert.Assertions) peer.ID {
327+
func getPeerID(t *testing.T) peer.ID {
329328
key := generateSingleKey()
330329

331330
peerID, err := peer.IDFromPrivateKey(key)
332-
assert.NoError(err)
331+
assert.NoError(t, err)
333332
return peerID
334333
}
335334

336335
// verifyTransactions checks if transactions are valid
337-
func verifyTransactions(node *FullNode, peerID peer.ID, assert *assert.Assertions) {
336+
func verifyTransactions(node *FullNode, peerID peer.ID, t *testing.T) {
338337
transactions := []string{"tx1", "tx2", "tx3", "tx4"}
339338
for _, tx := range transactions {
340339
err := node.Mempool.CheckTx([]byte(tx), func(r *abci.ResponseCheckTx) {}, mempool.TxInfo{
341340
SenderID: node.mempoolIDs.GetForPeer(peerID),
342341
})
343-
assert.NoError(err)
342+
assert.NoError(t, err)
344343
}
344+
345345
}
346346

347347
// verifyMempoolSize checks if the mempool size is as expected
348-
func verifyMempoolSize(node *FullNode, assert *assert.Assertions) {
349-
assert.NoError(testutils.Retry(300, 100*time.Millisecond, func() error {
348+
func verifyMempoolSize(node *FullNode, t *testing.T) {
349+
assert.NoError(t, testutils.Retry(300, 100*time.Millisecond, func() error {
350350
expectedSize := uint64(4 * len("tx*"))
351351
actualSize := uint64(node.Mempool.SizeBytes())
352352
if expectedSize == actualSize {

0 commit comments

Comments
 (0)