diff --git a/server/services/testdata/blocks_with_contract_calls.json b/server/services/testdata/blocks_with_contract_calls.json new file mode 100644 index 00000000..43f6a7d0 --- /dev/null +++ b/server/services/testdata/blocks_with_contract_calls.json @@ -0,0 +1,52 @@ +[ + { + "comment": "block with intra-shard contract call, with move balance, with signal error", + "miniBlocks": [ + { + "transactions": [ + { + "type": "normal", + "processingTypeOnSource": "SCInvoking", + "processingTypeOnDestination": "SCInvoking", + "hash": "9851ab6cb221bce5800030f9db2a5fbd8ed4a9db4c6f9d190c16113f2b080e57", + "value": "10000000000000000", + "receiver": "erd1qqqqqqqqqqqqqpgqagjekf5mxv86hy5c62vvtug5vc6jmgcsq6uq8reras", + "sender": "erd1tn62hjp72rznp8vq0lplva5csav6rccpqqdungpxtqz0g2hcq6uq9k4cc6", + "sourceShard": 0, + "destinationShard": 0, + "logs": { + "address": "erd1qqqqqqqqqqqqqpgqagjekf5mxv86hy5c62vvtug5vc6jmgcsq6uq8reras", + "events": [ + { + "address": "erd1qqqqqqqqqqqqqpgqagjekf5mxv86hy5c62vvtug5vc6jmgcsq6uq8reras", + "identifier": "signalError", + "topics": [ + "XPSryD5QxTCdgH/D9naYh1mh4wEAG8mgJlgE9Cr4Brg=", + "aW52YWxpZCBmdW5jdGlvbiAobm90IGZvdW5kKQ==" + ], + "data": "QDY2NzU2ZTYzNzQ2OTZmNmUyMDZlNmY3NDIwNjY2Zjc1NmU2NA==", + "additionalData": [ + "QDY2NzU2ZTYzNzQ2OTZmNmUyMDZlNmY3NDIwNjY2Zjc1NmU2NA==" + ] + }, + { + "address": "erd1tn62hjp72rznp8vq0lplva5csav6rccpqqdungpxtqz0g2hcq6uq9k4cc6", + "identifier": "internalVMErrors", + "topics": [ + "AAAAAAAAAAAFAOolmyabMw+rkpjSmMXxFGY1LaMQBrg=", + "bWlzc2luZ0Z1bmN0aW9u" + ], + "data": "CglydW50aW1lLmdvOjgzMSBbaW52YWxpZCBmdW5jdGlvbiAobm90IGZvdW5kKV0gW21pc3NpbmdGdW5jdGlvbl0=", + "additionalData": [ + "CglydW50aW1lLmdvOjgzMSBbaW52YWxpZCBmdW5jdGlvbiAobm90IGZvdW5kKV0gW21pc3NpbmdGdW5jdGlvbl0=" + ] + } + ] + }, + "initiallyPaidFee": "144050000000000" + } + ] + } + ] + } +] diff --git a/server/services/transactionsTransformer_test.go b/server/services/transactionsTransformer_test.go index 5bf89081..eb478050 100644 --- a/server/services/transactionsTransformer_test.go +++ b/server/services/transactionsTransformer_test.go @@ -298,7 +298,6 @@ func TestTransactionsTransformer_TransformBlockTxsHavingContractDeployments(t *t require.Nil(t, err) t.Run("direct contract deployment, with value", func(t *testing.T) { - txs, err := transformer.transformBlockTxs(blocks[0]) require.Nil(t, err) require.Len(t, txs, 1) @@ -373,6 +372,40 @@ func TestTransactionsTransformer_TransformBlockTxsHavingContractDeployments(t *t }) } +func TestTransactionsTransformer_TransformBlockTxsHavingContractCalls(t *testing.T) { + networkProvider := testscommon.NewNetworkProviderMock() + networkProvider.MockObservedActualShard = 0 + + extension := newNetworkProviderExtension(networkProvider) + transformer := newTransactionsTransformer(networkProvider) + + blocks, err := readTestBlocks("testdata/blocks_with_contract_calls.json") + require.Nil(t, err) + + t.Run("direct contract call, with value, with signal error", func(t *testing.T) { + txs, err := transformer.transformBlockTxs(blocks[0]) + require.Nil(t, err) + require.Len(t, txs, 1) + require.Len(t, txs[0].Operations, 1) + + expectedTx := &types.Transaction{ + TransactionIdentifier: hashToTransactionIdentifier("9851ab6cb221bce5800030f9db2a5fbd8ed4a9db4c6f9d190c16113f2b080e57"), + Operations: []*types.Operation{ + { + Type: opFee, + OperationIdentifier: indexToOperationIdentifier(0), + Account: addressToAccountIdentifier("erd1tn62hjp72rznp8vq0lplva5csav6rccpqqdungpxtqz0g2hcq6uq9k4cc6"), + Amount: extension.valueToNativeAmount("-144050000000000"), + Status: &opStatusSuccess, + }, + }, + Metadata: extractTransactionMetadata(blocks[0].MiniBlocks[0].Transactions[0]), + } + + require.Equal(t, expectedTx, txs[0]) + }) +} + func TestTransactionsTransformer_TransformBlockTxsHavingESDTIssue(t *testing.T) { networkProvider := testscommon.NewNetworkProviderMock() networkProvider.MockCustomCurrencies = []resources.Currency{{Symbol: "FOO-6d28db"}}