Skip to content

Commit 4974e85

Browse files
committed
fix: implement tx.transferSTX
1 parent b59e7d9 commit 4974e85

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

examples/counter/tests/counter_test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ Clarinet.test({
55
name: "Ensure that counter can be incremented multiples per block, accross multiple blocks",
66
async fn(chain: Chain, accounts: Map<string, Account>, contracts: Map<string, Contract>) {
77
let wallet_1 = accounts.get("wallet_1")!;
8+
let wallet_2 = accounts.get("wallet_2")!;
9+
810
let block = chain.mineBlock([
911
Tx.contractCall("counter", "increment", [types.uint(1)], wallet_1.address),
1012
Tx.contractCall("counter", "increment", [types.uint(4)], wallet_1.address),
@@ -24,7 +26,8 @@ Clarinet.test({
2426
block = chain.mineBlock([
2527
Tx.contractCall("counter", "increment", [types.uint(1)], wallet_1.address),
2628
Tx.contractCall("counter", "increment", [types.uint(4)], wallet_1.address),
27-
Tx.contractCall("counter", "increment", [types.uint(10)], wallet_1.address)
29+
Tx.contractCall("counter", "increment", [types.uint(10)], wallet_1.address),
30+
Tx.transferSTX(1, wallet_2.address, wallet_1.address),
2831
]);
2932

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

4144
let result = chain.getAssetsMaps();
42-
assertEquals(result.assets["STX"][wallet_1.address], 1000000);
45+
assertEquals(result.assets["STX"][wallet_1.address], 999999);
4346

4447
let call = chain.callReadOnlyFn("counter", "read-counter", [], wallet_1.address)
4548
call.result

src/test/deno.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,11 +820,15 @@ fn mine_block(state: &mut OpState, args: Value, _: ()) -> Result<String, AnyErro
820820
let execution = session.interpret(snippet, None, true, Some(name.into())).unwrap(); // todo(ludo)
821821
receipts.push((execution.result, execution.events));
822822
}
823-
824823
if let Some(ref args) = tx.deploy_contract {
825824
let execution = session.interpret(args.code.clone(), Some(args.name.clone()), true, Some(name.into())).unwrap(); // todo(ludo)
826825
receipts.push((execution.result, execution.events));
827826
}
827+
if let Some(ref args) = tx.transfer_stx {
828+
let snippet = format!("(stx-transfer? u{} tx-sender '{})", args.amount, args.recipient);
829+
let execution = session.interpret(snippet, None, true, Some(name.into())).unwrap(); // todo(ludo)
830+
receipts.push((execution.result, execution.events));
831+
}
828832
}
829833
session.set_tx_sender(initial_tx_sender);
830834
let block_height = session.advance_chain_tip(1);

0 commit comments

Comments
 (0)