Skip to content

Commit

Permalink
Additional tests: intra-shard contract calls, with value, with signal…
Browse files Browse the repository at this point in the history
… error.
  • Loading branch information
andreibancioiu committed Aug 20, 2024
1 parent cac7baf commit d0a6404
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 1 deletion.
52 changes: 52 additions & 0 deletions server/services/testdata/blocks_with_contract_calls.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
]
}
]
35 changes: 34 additions & 1 deletion server/services/transactionsTransformer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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"}}
Expand Down

0 comments on commit d0a6404

Please sign in to comment.