Skip to content

Commit

Permalink
check:cons works but with kava.ros from localnet
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeniy-scherbina committed Aug 9, 2024
1 parent 6562bef commit f78ef74
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 7 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ run-testnet:
run-local:
MODE=online NETWORK=kava-localnet PORT=8000 KAVA_RPC_URL=http://localhost:26657 go run . run

.PHONY: run-local-offline
run-local-offline:
MODE=offline NETWORK=kava-localnet PORT=8001 KAVA_RPC_URL=http://localhost:26657 go run . run

.PHONY: test
test:
go test -v ./...
Expand Down
6 changes: 3 additions & 3 deletions rosetta-cli-conf/kava-localnet-ci/config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"network": {
"blockchain": "Kava",
"network": "kava-testnet"
"network": "kava-localnet"
},
"online_url": "http://localhost:8000",
"data_directory": "./rosetta-cli-conf/cache",
Expand Down Expand Up @@ -31,9 +31,9 @@
"initial_balance_fetch_disabled": false,
"prefunded_accounts": [
{
"privkey": "4138d62905f516574d1301c805136ef391221ee6541adcd6cedf0c3adb04e34a",
"privkey": "6034eb3856dd7cca4b5d9bfc5f262ab155d967dc2f8b78485eae6a7cbb5e7c51",
"account_identifier": {
"address": "kava173kayarl9c8tl0m673ppcwkgv8v7kw496pqfpd"
"address": "kava173w2zz287s36ewnnkf4mjansnthnnsz7rtrxqc"
},
"curve_type": "secp256k1",
"currency":{
Expand Down
75 changes: 71 additions & 4 deletions rosetta-cli-conf/kava-localnet-ci/kava.ros
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
request_funds(1){
find_account{
currency = {"symbol":"KAVA", "decimals":6};
random_account = find_balance({
"minimum_balance": {
"value": "0",
"currency": {{currency}}
},
"create_limit":1
});
},
request{
loaded_account = find_balance({
"account_identifier": {{random_account.account_identifier}},
"minimum_balance":{
"value": "1000000",
"currency": {{currency}}
}
});
}
}

create_account(1){
create{
network = set_variable({"network":"kava-testnet", "blockchain":"Kava"});
network = set_variable({"network":"kava-localnet", "blockchain":"Kava"});
key = generate_key({"curve_type": "secp256k1"});
account = derive({
"network_identifier": {{network}},
Expand All @@ -13,9 +35,9 @@ create_account(1){
}
}

transfer(1){
transfer(10){
transfer{
transfer.network = set_variable({"network":"kava-testnet", "blockchain":"Kava"});
transfer.network = set_variable({"network":"kava-localnet", "blockchain":"Kava"});
currency = {"symbol":"KAVA", "decimals":6};
sender = find_balance({
"minimum_balance":{
Expand All @@ -26,7 +48,8 @@ transfer(1){

// Set the recipient_amount as some value <= sender.balance-max_fee
max_fee = "1000";
recipient_amount = "1001";
available_amount = {{sender.balance.value}} - {{max_fee}};
recipient_amount = random_number({"minimum": "1", "maximum": {{available_amount}}});
print_message({"recipient_amount":{{recipient_amount}}});

// Find recipient and construct operations
Expand Down Expand Up @@ -64,3 +87,47 @@ transfer(1){
];
}
}

return_funds(10){
transfer{
transfer.network = set_variable({"network":"kava-localnet", "blockchain":"Kava"});
currency = {"symbol":"KAVA", "decimals":6};
max_fee = "1000";
sender = find_balance({
"minimum_balance":{
"value": {{max_fee}},
"currency": {{currency}}
}
});

// Set the recipient_amount as some sender.balance-max_fee
available_amount = {{sender.balance.value}} - {{max_fee}};
print_message({"available_amount":{{available_amount}}});
sender_amount = 0 - {{available_amount}};

// Provide a static address as the recipient and construct operations
faucet = {"address":"kava1vlpsrmdyuywvaqrv7rx6xga224sqfwz3fyfhwq"};
transfer.confirmation_depth = "1";
transfer.operations = [
{
"operation_identifier":{"index":0},
"type":"transfer",
"account":{{sender.account_identifier}},
"amount":{
"value":{{sender_amount}},
"currency":{{currency}}
}
},
{
"operation_identifier":{"index":1},
"related_operations":[{"index":0}],
"type":"transfer",
"account":{{faucet}},
"amount":{
"value":{{available_amount}},
"currency":{{currency}}
}
}
];
}
}

0 comments on commit f78ef74

Please sign in to comment.