Skip to content

Commit

Permalink
Sketch a test configuration.
Browse files Browse the repository at this point in the history
  • Loading branch information
andreibancioiu committed Aug 1, 2024
1 parent 33ce0d9 commit 665560a
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
3 changes: 3 additions & 0 deletions server/services/constructionService.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ func (service *constructionService) computeData(options *constructionOptions) []
}

func (service *constructionService) computeDataForCustomCurrencyTransfer(tokenIdentifier string, amount string) []byte {
// Only fungible tokens are supported (at least, for now).
data := fmt.Sprintf("%s@%s@%s", builtInFunctionESDTTransfer, stringToHex(tokenIdentifier), amountToHex(amount))
return []byte(data)
}
Expand Down Expand Up @@ -248,6 +249,7 @@ func (service *constructionService) ConstructionParse(

func (service *constructionService) createOperationsFromPreparedTx(tx *data.Transaction) ([]*types.Operation, error) {
var operations []*types.Operation

isCustomCurrencyTransfer := isCustomCurrencyTransfer(string(tx.Data))

if isCustomCurrencyTransfer {
Expand All @@ -269,6 +271,7 @@ func (service *constructionService) createOperationsFromPreparedTx(tx *data.Tran
},
}
} else {
// Native currency transfer
operations = []*types.Operation{
{
Type: opTransfer,
Expand Down
35 changes: 35 additions & 0 deletions systemtests/devnet-construction.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"network": {
"blockchain": "MultiversX",
"network": "devnet"
},
"data_directory": "",
"http_timeout": 200,
"max_retries": 3,
"max_online_connections": 120,
"max_sync_concurrency": 1,
"construction": {
"end_conditions": {
"transfer": 2
},
"stale_depth": 10,
"broadcast_limit": 5,
"constructor_dsl_file": "devnet-construction.ros",
"prefunded_accounts": [
{
"account_identifier": {
"address": "erd1ldjsdetjvegjdnda0qw2h62kq6rpvrklkc5pw9zxm0nwulfhtyqqtyc4vq"
},
"privkey": "3e4e89e501eb542c12403fb15c52479e8721f2f4dedc3b3ef0f3b47b37de006c",
"curve_type": "edwards25519",
"currency": {
"symbol": "EGLD",
"decimals": 18
}
}
]
},
"data": {
"inactive_discrepancy_search_disabled": true
}
}
37 changes: 37 additions & 0 deletions systemtests/devnet-construction.ros
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
transfer(1){
transfer{
transfer.network = {"network":"devnet", "blockchain":"MultiversX"};
native_currency = {"symbol":"EGLD", "decimals":18};
sender = {
"account_identifier": {
"address": "erd1ldjsdetjvegjdnda0qw2h62kq6rpvrklkc5pw9zxm0nwulfhtyqqtyc4vq"
},
"currency": {
"symbol": "EGLD",
"decimals": 18
}
};

max_transfer_amount = "10000000000000000";
recipient_amount = random_number({"minimum": "1", "maximum": {{max_transfer_amount}}});

print_message({"recipient_amount":{{recipient_amount}}});

sender_amount = 0-{{recipient_amount}};
transfer.confirmation_depth = "10";
transfer.operations = [
{
"operation_identifier":{"index":0},
"type":"Transfer",
"account":{{sender.account_identifier}},
"amount":{
"value":{{sender_amount}},
"currency":{{native_currency}}
}
}
];
transfer.preprocess_metadata = {
"receiver": "erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th"
};
}
}

0 comments on commit 665560a

Please sign in to comment.