Skip to content

Commit

Permalink
fix: correct outdated depositor.did (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
sesi200 committed Nov 30, 2023
1 parent 130a031 commit a4292c5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
4 changes: 2 additions & 2 deletions depositor/depositor.did
@@ -1,5 +1,5 @@
type Account = record { owner : principal; subaccount : opt vec nat8 };
type DepositArg = record { to : Account; memo : opt vec nat8; cycles : nat };
type DepositResult = record { balance : nat; txid : nat };
type DepositResult = record { balance : nat; block_index : nat };
type InitArg = record { ledger_id : principal };
service : (InitArg) -> { deposit : (DepositArg) -> (DepositResult) }
service : (InitArg) -> { deposit : (DepositArg) -> (DepositResult) };
28 changes: 28 additions & 0 deletions depositor/src/main.rs
Expand Up @@ -42,3 +42,31 @@ async fn deposit(arg: DepositArg) -> DepositResult {
.expect("Unable to call deposit");
result
}

#[test]
fn test_candid_interface_compatibility() {
use candid::utils::{service_equal, CandidSource};
use std::path::PathBuf;

candid::export_service!();
let exported_interface = __export_service();

let expected_interface =
PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap()).join("depositor.did");

println!(
"Expected interface: {}\n\n",
CandidSource::File(expected_interface.as_path())
.load()
.unwrap()
.1
.unwrap()
);
println!("Exported interface: {}\n\n", exported_interface);

service_equal(
CandidSource::Text(&exported_interface),
CandidSource::File(expected_interface.as_path()),
)
.expect("The despositor interface is not compatible with the depositor.did file");
}

0 comments on commit a4292c5

Please sign in to comment.