Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: add return_funds to oasis.ros #269

Open
pro-wh opened this issue Jan 19, 2022 · 0 comments
Open

tests: add return_funds to oasis.ros #269

pro-wh opened this issue Jan 19, 2022 · 0 comments

Comments

@pro-wh
Copy link
Collaborator

pro-wh commented Jan 19, 2022

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}}}
    }];
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant