Skip to content

Commit ab5a2c5

Browse files
Adjust tests.
1 parent 946eee9 commit ab5a2c5

File tree

2 files changed

+66
-40
lines changed

2 files changed

+66
-40
lines changed

server/services/testdata/blocks_with_claim_developer_rewards.json

Lines changed: 55 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,48 @@
88
"type": "normal",
99
"processingTypeOnSource": "BuiltInFunctionCall",
1010
"processingTypeOnDestination": "BuiltInFunctionCall",
11-
"hash": "96b1a0533ff17df3d1777889117023d0b178cc80fa72535d1b8ec1a13bcf3a75",
12-
"epoch": 20,
11+
"hash": "e0cb3e108c4e04a6d2406d718c20f976b365de3d1dd0067fd2fae996f7c9cbd1",
12+
"nonce": 536,
13+
"round": 1092226,
14+
"epoch": 909,
1315
"value": "0",
14-
"receiver": "erd1qqqqqqqqqqqqqpgqagjekf5mxv86hy5c62vvtug5vc6jmgcsq6uq8reras",
16+
"receiver": "erd1qqqqqqqqqqqqqpgq2kndhnp65u9jvg79pz6luthf2tcfc9f6q6uq28n2n9",
1517
"sender": "erd1tn62hjp72rznp8vq0lplva5csav6rccpqqdungpxtqz0g2hcq6uq9k4cc6",
18+
"gasPrice": 1000000000,
19+
"gasLimit": 8000000,
1620
"data": "Q2xhaW1EZXZlbG9wZXJSZXdhcmRz",
17-
"signature": "132aa54ec093c21e2d0d447bf9a9b1da5c33d4120da66fb53dbc78d1d3d007e2314fa06348302f503e96a91b697dd943189df0ad4c3750416a704de2ac007e06",
21+
"signature": "b8771fe3f0184bed47f002543f5302b93bfeace7cf1c3ef138522e4c53e162745359d4eb4fa2cf40036ebc1c4db9e8269ea5b81047aa6d9f6965c5792d84e40e",
1822
"sourceShard": 0,
1923
"destinationShard": 0,
24+
"miniblockType": "TxBlock",
25+
"miniblockHash": "2684c32382e5acd3912d8ae7adfa934e1950d24927f0b99baae6617182a1eae8",
2026
"logs": {
21-
"address": "erd1qqqqqqqqqqqqqpgqagjekf5mxv86hy5c62vvtug5vc6jmgcsq6uq8reras",
27+
"address": "erd1qqqqqqqqqqqqqpgq2kndhnp65u9jvg79pz6luthf2tcfc9f6q6uq28n2n9",
2228
"events": [
2329
{
24-
"address": "erd1qqqqqqqqqqqqqpgqagjekf5mxv86hy5c62vvtug5vc6jmgcsq6uq8reras",
30+
"address": "erd1qqqqqqqqqqqqqpgq2kndhnp65u9jvg79pz6luthf2tcfc9f6q6uq28n2n9",
31+
"identifier": "ClaimDeveloperRewards",
32+
"topics": [
33+
"AZ012mtA",
34+
"XPSryD5QxTCdgH/D9naYh1mh4wEAG8mgJlgE9Cr4Brg="
35+
],
36+
"data": null,
37+
"additionalData": null
38+
},
39+
{
40+
"address": "erd1qqqqqqqqqqqqqpgq2kndhnp65u9jvg79pz6luthf2tcfc9f6q6uq28n2n9",
2541
"identifier": "completedTxEvent",
2642
"topics": [
27-
"lrGgUz/xffPRd3iJEXAj0LF4zID6clNdG47BoTvPOnU="
43+
"4Ms+EIxOBKbSQG1xjCD5drNl3j0d0AZ/0vrplvfJy9E="
2844
],
2945
"data": null,
3046
"additionalData": null
3147
}
3248
]
3349
},
50+
"status": "success",
3451
"operation": "ClaimDeveloperRewards",
52+
"function": "ClaimDeveloperRewards",
3553
"initiallyPaidFee": "160685000000000"
3654
}
3755
]
@@ -42,33 +60,50 @@
4260
"type": "unsigned",
4361
"processingTypeOnSource": "MoveBalance",
4462
"processingTypeOnDestination": "MoveBalance",
45-
"hash": "d05c5f65f564d740aa1e81f7a96581d739783a43c232a6c86112afa1e6c318c4",
46-
"epoch": 20,
63+
"hash": "7969b30a33e9d925cacda530a4afa74269cd4e366f0598486e23b70f5e10cf98",
64+
"nonce": 0,
65+
"round": 1092226,
66+
"epoch": 909,
4767
"value": "1774725000000",
4868
"receiver": "erd1tn62hjp72rznp8vq0lplva5csav6rccpqqdungpxtqz0g2hcq6uq9k4cc6",
4969
"sender": "erd1tn62hjp72rznp8vq0lplva5csav6rccpqqdungpxtqz0g2hcq6uq9k4cc6",
50-
"previousTransactionHash": "96b1a0533ff17df3d1777889117023d0b178cc80fa72535d1b8ec1a13bcf3a75",
51-
"originalTransactionHash": "96b1a0533ff17df3d1777889117023d0b178cc80fa72535d1b8ec1a13bcf3a75",
70+
"gasPrice": 1000000000,
71+
"previousTransactionHash": "e0cb3e108c4e04a6d2406d718c20f976b365de3d1dd0067fd2fae996f7c9cbd1",
72+
"originalTransactionHash": "e0cb3e108c4e04a6d2406d718c20f976b365de3d1dd0067fd2fae996f7c9cbd1",
5273
"originalSender": "erd1tn62hjp72rznp8vq0lplva5csav6rccpqqdungpxtqz0g2hcq6uq9k4cc6",
5374
"sourceShard": 0,
54-
"destinationShard": 0
75+
"destinationShard": 0,
76+
"miniblockType": "SmartContractResultBlock",
77+
"miniblockHash": "8ba6961a4191dc4f42296eab4f68a56048fd257c943f4e787e31befb8b155d84",
78+
"status": "success",
79+
"operation": "transfer",
80+
"callType": "directCall",
81+
"options": 0
5582
},
5683
{
5784
"type": "unsigned",
5885
"processingTypeOnSource": "MoveBalance",
5986
"processingTypeOnDestination": "MoveBalance",
60-
"hash": "bc89442d5e77113f0b4e7383e5d078776fc6724690ba9f98d1704202c324e090",
61-
"epoch": 20,
87+
"hash": "06f81486996225b597bc7ed89b4062cd895491b33b1e81f34205ef48272bd644",
88+
"nonce": 537,
89+
"round": 1092226,
90+
"epoch": 909,
6291
"value": "29185000000000",
6392
"receiver": "erd1tn62hjp72rznp8vq0lplva5csav6rccpqqdungpxtqz0g2hcq6uq9k4cc6",
64-
"sender": "erd1qqqqqqqqqqqqqpgqagjekf5mxv86hy5c62vvtug5vc6jmgcsq6uq8reras",
65-
"previousTransactionHash": "96b1a0533ff17df3d1777889117023d0b178cc80fa72535d1b8ec1a13bcf3a75",
66-
"originalTransactionHash": "96b1a0533ff17df3d1777889117023d0b178cc80fa72535d1b8ec1a13bcf3a75",
93+
"sender": "erd1qqqqqqqqqqqqqpgq2kndhnp65u9jvg79pz6luthf2tcfc9f6q6uq28n2n9",
94+
"gasPrice": 1000000000,
95+
"data": "QDZmNmI=",
96+
"previousTransactionHash": "e0cb3e108c4e04a6d2406d718c20f976b365de3d1dd0067fd2fae996f7c9cbd1",
97+
"originalTransactionHash": "e0cb3e108c4e04a6d2406d718c20f976b365de3d1dd0067fd2fae996f7c9cbd1",
6798
"sourceShard": 0,
6899
"destinationShard": 0,
69-
"nonce": 29,
70-
"data": "QDZmNmI=",
71-
"isRefund": true
100+
"miniblockType": "SmartContractResultBlock",
101+
"miniblockHash": "8ba6961a4191dc4f42296eab4f68a56048fd257c943f4e787e31befb8b155d84",
102+
"status": "success",
103+
"operation": "transfer",
104+
"isRefund": true,
105+
"callType": "directCall",
106+
"options": 0
72107
}
73108
]
74109
}

server/services/transactionsTransformer_test.go

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,16 +1260,15 @@ func TestTransactionsTransformer_TransformBlockTxsHavingClaimDeveloperRewards(t
12601260
blocks, err := readTestBlocks("testdata/blocks_with_claim_developer_rewards.json")
12611261
require.Nil(t, err)
12621262

1263-
t.Run("recover operations in legacy manner (without using events)", func(t *testing.T) {
1263+
t.Run("recover operations", func(t *testing.T) {
12641264
txs, err := transformer.transformBlockTxs(blocks[0])
12651265
require.Nil(t, err)
1266-
require.Len(t, txs, 3)
1267-
require.Len(t, txs[0].Operations, 1)
1266+
require.Len(t, txs, 2)
1267+
require.Len(t, txs[0].Operations, 2)
12681268
require.Len(t, txs[1].Operations, 1)
1269-
require.Len(t, txs[2].Operations, 1)
12701269

12711270
expectedTx0 := &types.Transaction{
1272-
TransactionIdentifier: hashToTransactionIdentifier("96b1a0533ff17df3d1777889117023d0b178cc80fa72535d1b8ec1a13bcf3a75"),
1271+
TransactionIdentifier: hashToTransactionIdentifier("e0cb3e108c4e04a6d2406d718c20f976b365de3d1dd0067fd2fae996f7c9cbd1"),
12731272
Operations: []*types.Operation{
12741273
{
12751274
Type: opFee,
@@ -1278,30 +1277,22 @@ func TestTransactionsTransformer_TransformBlockTxsHavingClaimDeveloperRewards(t
12781277
Amount: extension.valueToNativeAmount("-160685000000000"),
12791278
Status: &opStatusSuccess,
12801279
},
1281-
},
1282-
Metadata: extractTransactionMetadata(blocks[0].MiniBlocks[0].Transactions[0]),
1283-
}
1284-
1285-
require.Equal(t, expectedTx0, txs[0])
1286-
1287-
expectedTx1 := &types.Transaction{
1288-
TransactionIdentifier: hashToTransactionIdentifier("d05c5f65f564d740aa1e81f7a96581d739783a43c232a6c86112afa1e6c318c4"),
1289-
Operations: []*types.Operation{
12901280
{
1291-
Type: opDeveloperRewardsAsScResult,
1292-
OperationIdentifier: indexToOperationIdentifier(0),
1281+
Type: opDeveloperRewards,
1282+
OperationIdentifier: indexToOperationIdentifier(1),
12931283
Account: addressToAccountIdentifier("erd1tn62hjp72rznp8vq0lplva5csav6rccpqqdungpxtqz0g2hcq6uq9k4cc6"),
12941284
Amount: extension.valueToNativeAmount("1774725000000"),
12951285
Status: &opStatusSuccess,
12961286
},
12971287
},
1288+
Metadata: extractTransactionMetadata(blocks[0].MiniBlocks[0].Transactions[0]),
12981289
}
12991290

1300-
require.Equal(t, expectedTx1, txs[1])
1291+
require.Equal(t, expectedTx0, txs[0])
13011292

13021293
// Fee refund
1303-
expectedTx2 := &types.Transaction{
1304-
TransactionIdentifier: hashToTransactionIdentifier("bc89442d5e77113f0b4e7383e5d078776fc6724690ba9f98d1704202c324e090"),
1294+
expectedTx1 := &types.Transaction{
1295+
TransactionIdentifier: hashToTransactionIdentifier("06f81486996225b597bc7ed89b4062cd895491b33b1e81f34205ef48272bd644"),
13051296
Operations: []*types.Operation{
13061297
{
13071298
Type: opFeeRefundAsScResult,
@@ -1313,7 +1304,7 @@ func TestTransactionsTransformer_TransformBlockTxsHavingClaimDeveloperRewards(t
13131304
},
13141305
}
13151306

1316-
require.Equal(t, expectedTx2, txs[2])
1307+
require.Equal(t, expectedTx1, txs[1])
13171308
})
13181309
}
13191310

0 commit comments

Comments
 (0)