Skip to content

Commit 96d9352

Browse files
committed
test: add function-level comments to tests
1 parent ced4961 commit 96d9352

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

backend/pkg/commons/rpc/utils_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ var (
1717
token2 = common.HexToAddress("0xabcdef1234567890abcdef1234567890abcdef12")
1818
)
1919

20+
// TestGetReceiver tests the getReceiver function, which extracts the recipient
21+
// address from a transaction.
2022
func TestGetReceiver(t *testing.T) {
2123
tests := []struct {
2224
name string
@@ -45,6 +47,8 @@ func TestGetReceiver(t *testing.T) {
4547
}
4648
}
4749

50+
// TestGetBlockWithdrawals tests the getBlockWithdrawals function, which
51+
// converts a list of withdrawals from a block into a list of Eth1Withdrawal type.
4852
func TestGetBlockWithdrawals(t *testing.T) {
4953
tests := []struct {
5054
name string
@@ -132,6 +136,8 @@ func TestGetBlockWithdrawals(t *testing.T) {
132136
}
133137
}
134138

139+
// TestGetLogsFromReceipts tests the getLogsFromReceipts function, which converts
140+
// a list of logs from a receipt into a list of Eth1Log type
135141
func TestGetLogsFromReceipts(t *testing.T) {
136142
tests := []struct {
137143
name string
@@ -240,6 +246,8 @@ func TestGetLogsFromReceipts(t *testing.T) {
240246
}
241247
}
242248

249+
// TestGetTokens tests the getTokens function, which converts a list of token
250+
// addresses from a transaction into a list of common.Address type
243251
func TestGetTokens(t *testing.T) {
244252
tests := []struct {
245253
name string
@@ -278,6 +286,9 @@ func TestGetTokens(t *testing.T) {
278286
}
279287
}
280288

289+
// TestParseAddressBalance tests the parseAddressBalance function, which converts
290+
// a list of token addresses, address and a list of balances into a list of
291+
// Eth1AddressBalance type
281292
func TestParseAddressBalance(t *testing.T) {
282293
tests := []struct {
283294
name string

backend/pkg/executionlayer/transformer_test.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,6 +1216,8 @@ func TestTransformer_FromList(t *testing.T) {
12161216
}
12171217
}
12181218

1219+
// TestIsValidERC20Log tests the isValidERC20Log function to verify
1220+
// if the log is a valid ERC20 transfer log
12191221
func TestIsValidERC20Log(t *testing.T) {
12201222
tests := []struct {
12211223
name string
@@ -1278,6 +1280,8 @@ func TestIsValidERC20Log(t *testing.T) {
12781280
}
12791281
}
12801282

1283+
// TestIsValidERC721Log tests the isValidERC721Log function to verify
1284+
// if the log is a valid ERC721 transfer log
12811285
func TestIsValidERC721Log(t *testing.T) {
12821286
tests := []struct {
12831287
name string
@@ -1344,6 +1348,8 @@ func TestIsValidERC721Log(t *testing.T) {
13441348
}
13451349
}
13461350

1351+
// TestIsValidERC1155Log tests the isValidERC1155Log function to verify
1352+
// if the log is a valid ERC1155 transfer log
13471353
func TestIsValidERC1155Log(t *testing.T) {
13481354
tests := []struct {
13491355
name string
@@ -1446,6 +1452,8 @@ func TestIsValidERC1155Log(t *testing.T) {
14461452
}
14471453
}
14481454

1455+
// TestIsValidItx tests the isValidItx function to verify
1456+
// if the internal transactions are valid and can be indexed
14491457
func TestIsValidItx(t *testing.T) {
14501458
tests := []struct {
14511459
name string
@@ -1496,6 +1504,8 @@ func TestIsValidItx(t *testing.T) {
14961504
}
14971505
}
14981506

1507+
// TestGetLogTopics tests the getLogTopics function to verify
1508+
// if the function correctly extracts the topics from the log
14991509
func TestGetLogTopics(t *testing.T) {
15001510
topic1 := "0x1234"
15011511
topic2 := "0x2345"
@@ -1544,6 +1554,8 @@ func TestGetLogTopics(t *testing.T) {
15441554
}
15451555
}
15461556

1557+
// TestGetTxRecipient tests the getTxRecipient function to verify
1558+
// if the function correctly extracts the recipients from the transaction
15471559
func TestGetTxRecipient(t *testing.T) {
15481560
tests := []struct {
15491561
name string
@@ -1592,6 +1604,8 @@ func TestGetTxRecipient(t *testing.T) {
15921604
}
15931605
}
15941606

1607+
// TestGetTokenID tests the getTokenID function to verify
1608+
// if the function correctly extracts the token ID from the transfer
15951609
func TestGetTokenID(t *testing.T) {
15961610
tests := []struct {
15971611
name string
@@ -1624,6 +1638,8 @@ func TestGetTokenID(t *testing.T) {
16241638
}
16251639
}
16261640

1641+
// TestGetMethodsSignature tests the getMethodSignature function to verify
1642+
// if the function correctly extracts the method signature from the transaction
16271643
func TestGetMethodSignature(t *testing.T) {
16281644
tests := []struct {
16291645
name string
@@ -1670,6 +1686,8 @@ func TestGetMethodSignature(t *testing.T) {
16701686
}
16711687
}
16721688

1689+
// TestGetContractAddress tests the getContractAddress function to verify
1690+
// if the function correctly extracts the contract address from the internal transaction
16731691
func TestGetContractAddress(t *testing.T) {
16741692
tests := []struct {
16751693
name string
@@ -1715,6 +1733,8 @@ func TestGetContractAddress(t *testing.T) {
17151733
}
17161734
}
17171735

1736+
// TestGetERC20TransferValue tests getERC20TransferValue function to verify
1737+
// if the function correctly extracts the ERC20 transfer value from the ERC20 transfer contract
17181738
func TestGetERC20TransferValue(t *testing.T) {
17191739
tests := []struct {
17201740
name string
@@ -1747,6 +1767,8 @@ func TestGetERC20TransferValue(t *testing.T) {
17471767
}
17481768
}
17491769

1770+
// TestGetERC1155TransferIDs tests getERC1155TransferIDs function to verify
1771+
// if the function correctly extracts the ERC1155 transfer IDs from the ID list
17501772
func TestGetERC1155TransferIDs(t *testing.T) {
17511773
tests := []struct {
17521774
name string
@@ -1797,6 +1819,8 @@ func TestGetERC1155TransferIDs(t *testing.T) {
17971819
}
17981820
}
17991821

1822+
// TestGetERC1155TransferValues tests getERC1155TransferValues function to verify
1823+
// if the function correctly extracts the ERC1155 transfer values from the value list
18001824
func TestGetERC1155TransferValues(t *testing.T) {
18011825
tests := []struct {
18021826
name string
@@ -1847,6 +1871,8 @@ func TestGetERC1155TransferValues(t *testing.T) {
18471871
}
18481872
}
18491873

1874+
// TestUpdateITxStatus tests the updateITxStatus function to verify
1875+
// if the function correctly updates the status of the internal transaction
18501876
func TestUpdateITxStatus(t *testing.T) {
18511877
tests := []struct {
18521878
name string
@@ -1921,6 +1947,8 @@ func TestUpdateITxStatus(t *testing.T) {
19211947
}
19221948
}
19231949

1950+
// TestCalculateTxFee tests the calculateTxFee function to verify
1951+
// if the function correctly calculates the transaction fee
19241952
func TestCalculateTxFee(t *testing.T) {
19251953
tests := []struct {
19261954
name string
@@ -1960,6 +1988,8 @@ func TestCalculateTxFee(t *testing.T) {
19601988
}
19611989
}
19621990

1991+
// TestCalculateMevFromBlock tests the calculateMevFromBlock function to verify
1992+
// if the function correctly calculates the MEV from the block
19631993
func TestCalculateMevFromBlock(t *testing.T) {
19641994
tests := []struct {
19651995
name string
@@ -2014,6 +2044,8 @@ func TestCalculateMevFromBlock(t *testing.T) {
20142044
}
20152045
}
20162046

2047+
// TestCalculateBlockUncleReward tests the calculateBlockUncleReward function to verify
2048+
// if the function correctly calculates the uncle reward from the block
20172049
func TestCalculateBlockUncleReward(t *testing.T) {
20182050
tests := []struct {
20192051
name string
@@ -2086,6 +2118,8 @@ func TestCalculateBlockUncleReward(t *testing.T) {
20862118
}
20872119
}
20882120

2121+
// TestCalculateUncleReward tests the calculateUncleReward function to verify
2122+
// if the function correctly calculates the single uncle reward
20892123
func TestCalculateUncleReward(t *testing.T) {
20902124
tests := []struct {
20912125
name string
@@ -2138,6 +2172,8 @@ func TestCalculateUncleReward(t *testing.T) {
21382172
}
21392173
}
21402174

2175+
// TestVerifyName tests the verifyName function to verify
2176+
// if the function correctly validates the name based on the length
21412177
func TestVerifyName(t *testing.T) {
21422178
tests := []struct {
21432179
name string

0 commit comments

Comments
 (0)