Skip to content

Commit

Permalink
fix: implement tx.transferSTX
Browse files Browse the repository at this point in the history
  • Loading branch information
lgalabru committed Jun 25, 2021
1 parent b59e7d9 commit 4974e85
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 5 additions & 2 deletions examples/counter/tests/counter_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Clarinet.test({
name: "Ensure that counter can be incremented multiples per block, accross multiple blocks",
async fn(chain: Chain, accounts: Map<string, Account>, contracts: Map<string, Contract>) {
let wallet_1 = accounts.get("wallet_1")!;
let wallet_2 = accounts.get("wallet_2")!;

let block = chain.mineBlock([
Tx.contractCall("counter", "increment", [types.uint(1)], wallet_1.address),
Tx.contractCall("counter", "increment", [types.uint(4)], wallet_1.address),
Expand All @@ -24,7 +26,8 @@ Clarinet.test({
block = chain.mineBlock([
Tx.contractCall("counter", "increment", [types.uint(1)], wallet_1.address),
Tx.contractCall("counter", "increment", [types.uint(4)], wallet_1.address),
Tx.contractCall("counter", "increment", [types.uint(10)], wallet_1.address)
Tx.contractCall("counter", "increment", [types.uint(10)], wallet_1.address),
Tx.transferSTX(1, wallet_2.address, wallet_1.address),
]);

assertEquals(block.height, 3);
Expand All @@ -39,7 +42,7 @@ Clarinet.test({
.expectUint(31);

let result = chain.getAssetsMaps();
assertEquals(result.assets["STX"][wallet_1.address], 1000000);
assertEquals(result.assets["STX"][wallet_1.address], 999999);

let call = chain.callReadOnlyFn("counter", "read-counter", [], wallet_1.address)
call.result
Expand Down
6 changes: 5 additions & 1 deletion src/test/deno.rs
Original file line number Diff line number Diff line change
Expand Up @@ -820,11 +820,15 @@ fn mine_block(state: &mut OpState, args: Value, _: ()) -> Result<String, AnyErro
let execution = session.interpret(snippet, None, true, Some(name.into())).unwrap(); // todo(ludo)
receipts.push((execution.result, execution.events));
}

if let Some(ref args) = tx.deploy_contract {
let execution = session.interpret(args.code.clone(), Some(args.name.clone()), true, Some(name.into())).unwrap(); // todo(ludo)
receipts.push((execution.result, execution.events));
}
if let Some(ref args) = tx.transfer_stx {
let snippet = format!("(stx-transfer? u{} tx-sender '{})", args.amount, args.recipient);
let execution = session.interpret(snippet, None, true, Some(name.into())).unwrap(); // todo(ludo)
receipts.push((execution.result, execution.events));
}
}
session.set_tx_sender(initial_tx_sender);
let block_height = session.advance_chain_tip(1);
Expand Down

0 comments on commit 4974e85

Please sign in to comment.