oasis-rosetta-gateway
oasis-rosetta-gateway copied to clipboard
tests: add return_funds to oasis.ros
we've received a draft of this from our partner, which was testing on the testnet
// Portions of this are modeled after Rosetta's Ethereum transfer test, which
// also uses an accounts based model.
// https://github.com/coinbase/rosetta-ethereum/blob/master/rosetta-cli-conf/testnet/ethereum.ros
create_account(1){
create{
key = generate_key({"curve_type": "edwards25519"});
account = derive({
"network_identifier": {
"blockchain": "Oasis",
"network": "5ba68bc5e01e06f755c4c044dd11ec508e4c17f1faf40c0e67874388437a9e55"
},
"public_key": {{key.public_key}}
});
save_account({
"account_identifier": {{account.account_identifier}},
"keypair": {{key}}
});
}
}
transfer(10){
transfer{
transfer.network = {
"blockchain": "Oasis",
"network": "5ba68bc5e01e06f755c4c044dd11ec508e4c17f1faf40c0e67874388437a9e55"
};
fee_accumulator = {
"address": "oasis1qqnv3peudzvekhulf8v3ht29z4cthkhy7gkxmph5"
};
currency = {"symbol": "ROSE", "decimals": 9};
sender = find_balance({
"minimum_balance": {"value": "101", "currency": {{currency}}}
});
amount_fee = "100";
sender_amount_fee = 0 - {{amount_fee}};
available_amount = {{sender.balance.value}} - {{amount_fee}};
recipient_amount = random_number({"minimum": "1", "maximum": {{available_amount}}});
print_message({"recipient_amount": {{recipient_amount}}});
sender_amount = 0 - {{recipient_amount}};
recipient = find_balance({
"not_account_identifier": [{{sender.account_identifier}}],
"minimum_balance": {"value": "0", "currency": {{currency}}},
"create_limit": 100,
"create_probability": 50
});
transfer.confirmation_depth = "1";
transfer.operations = [{
"operation_identifier": {"index": 0},
"type": "Transfer",
"account": {{sender.account_identifier}},
"amount": {"value": {{sender_amount_fee}}, "currency": {{currency}}}
},
{
"operation_identifier": {"index": 1},
"type": "Transfer",
"account": {{fee_accumulator}},
"amount": {"value": {{amount_fee}}, "currency": {{currency}}}
},
{
"operation_identifier": {"index": 2},
"type": "Transfer",
"account": {{sender.account_identifier}},
"amount": {"value": {{sender_amount}}, "currency": {{currency}}}
},
{
"operation_identifier": {"index": 3},
"type": "Transfer",
"account": {{recipient.account_identifier}},
"amount": {"value": {{recipient_amount}}, "currency": {{currency}}}
}];
}
}
return_funds(10){
transfer{
transfer.network = {
"blockchain": "Oasis",
"network": "5ba68bc5e01e06f755c4c044dd11ec508e4c17f1faf40c0e67874388437a9e55"
};
fee_accumulator = {
"address": "oasis1qqnv3peudzvekhulf8v3ht29z4cthkhy7gkxmph5"
};
currency = {"symbol": "ROSE", "decimals": 9};
recipient = find_balance({
"account_identifier": {"address":"oasis1qpfcr953qggrq6889zczf5rth3xw4qfhhgh4zyhy"},
"minimum_balance": {"value": "0", "currency": {{currency}}}
});
sender = find_balance({
"minimum_balance": {"value": "101", "currency": {{currency}}},
"not_account_identifier": [{{recipient.account_identifier}}]
});
amount_fee = "100";
sender_amount_fee = 0 - {{amount_fee}};
available_amount = {{sender.balance.value}} - {{amount_fee}};
recipient_amount = random_number({"minimum": "1", "maximum": {{available_amount}}});
print_message({"recipient_amount": {{recipient_amount}}});
sender_amount = 0 - {{recipient_amount}};
transfer.confirmation_depth = "1";
transfer.operations = [{
"operation_identifier": {"index": 0},
"type": "Transfer",
"account": {{sender.account_identifier}},
"amount": {"value": {{sender_amount_fee}}, "currency": {{currency}}}
},
{
"operation_identifier": {"index": 1},
"type": "Transfer",
"account": {{fee_accumulator}},
"amount": {"value": {{amount_fee}}, "currency": {{currency}}}
},
{
"operation_identifier": {"index": 2},
"type": "Transfer",
"account": {{sender.account_identifier}},
"amount": {"value": {{sender_amount}}, "currency": {{currency}}}
},
{
"operation_identifier": {"index": 3},
"type": "Transfer",
"account": {{recipient.account_identifier}},
"amount": {"value": {{recipient_amount}}, "currency": {{currency}}}
}];
}
}