Skip to content

Commit 5d585e7

Browse files
committed
fix wallet tests
1 parent 75af18d commit 5d585e7

2 files changed

Lines changed: 16 additions & 9 deletions

File tree

examples/wallet/script/src/host.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,13 @@ impl HostInterface for MockHost {
201201
None => msg,
202202
};
203203

204-
AthenaVm::new().execute(self, AthenaRevision::AthenaFrontier, msg, &code)
204+
AthenaVm::new().execute(
205+
self,
206+
AthenaRevision::AthenaFrontier,
207+
msg,
208+
&code,
209+
Address::default(),
210+
)
205211
} else {
206212
let gas_left = msg.gas.checked_sub(1).expect("gas underflow");
207213
ExecutionResult::new(StatusCode::Success, gas_left, None)

examples/wallet/script/src/main.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use host::*;
99

1010
use std::error::Error;
1111

12-
use athena_interface::{Address, AthenaContext, Encode, MethodSelector};
12+
use athena_interface::{Address, AthenaContext, CallerBuilder, Encode, MethodSelector};
1313
use athena_sdk::{host::HostInterface, AthenaStdin, ExecutionClient};
1414
use athena_vm_sdk::{wallet::SpendArguments, Pubkey};
1515

@@ -50,8 +50,8 @@ fn main() {
5050
);
5151

5252
// send some coins
53-
let address_bob = Address::from([0xBB; 24]);
54-
let context = AthenaContext::new(ADDRESS_ALICE, address_bob, 0);
53+
let caller = CallerBuilder::new(Address::from([0xBB; 24])).build();
54+
let context = AthenaContext::new(ADDRESS_ALICE, caller, 0);
5555

5656
let mut stdin = AthenaStdin::new();
5757
let wallet = host
@@ -70,9 +70,7 @@ fn main() {
7070
assert!(alice_balance >= 120);
7171
println!(
7272
"sending {} coins {} -> {}",
73-
args.amount,
74-
context.address(),
75-
args.recipient,
73+
args.amount, context.caller.account, args.recipient,
7674
);
7775
// calculate method selector
7876
let method_selector = MethodSelector::from("athexp_spend");
@@ -107,7 +105,7 @@ mod tests {
107105
payload::ExecutionPayloadBuilder, payload::Payload, Address, AthenaMessage, Balance, Encode,
108106
MessageKind, MethodSelector, StatusCode,
109107
};
110-
use athena_interface::{AthenaContext, Decode, ExecutionResult};
108+
use athena_interface::{AthenaContext, CallerBuilder, Decode, ExecutionResult};
111109
use athena_runner::vm::AthenaRevision;
112110
use athena_runner::AthenaVm;
113111
use athena_sdk::host::MockHostInterface;
@@ -241,6 +239,7 @@ mod tests {
241239
Balance::default(),
242240
),
243241
super::ELF,
242+
Address::default(),
244243
);
245244

246245
// the call should succeed, and it should return false
@@ -274,6 +273,7 @@ mod tests {
274273
Balance::default(),
275274
),
276275
super::ELF,
276+
Address::default(),
277277
);
278278

279279
// the call should succeed, and it should return true
@@ -327,9 +327,10 @@ mod tests {
327327
stdin.write_vec(args.encode());
328328

329329
let sender = ADDRESS_ALICE;
330-
let context = AthenaContext::new(sender, Address::default(), 0);
330+
let context = AthenaContext::new(sender, CallerBuilder::new(Address::default()).build(), 0);
331331
let mut host = MockHostInterface::new();
332332
host.expect_call().returning(move |msg| {
333+
// the callee becomes the sender in the proxied call
333334
assert_eq!(sender, msg.sender);
334335
assert_eq!(args.destination, msg.recipient);
335336
assert_eq!(args.amount, msg.value);

0 commit comments

Comments
 (0)