Skip to content

Commit

Permalink
fix: fix cross contract call for only registrar can create TLA
Browse files Browse the repository at this point in the history
  • Loading branch information
fospring committed Jun 23, 2024
1 parent 4931403 commit 563f333
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
2 changes: 1 addition & 1 deletion examples/src/gen/adder.rs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
// No content here, it's to be generated on build. Here to allow cargofmt to work.
// No content here, it's to be generated on build. Here to allow cargofmt to work.
21 changes: 7 additions & 14 deletions workspaces/tests/cross_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,17 @@ async fn test_cross_contract_create_contract() -> anyhow::Result<()> {

// Expect to fail for trying to create a new contract account with too short of a
// top level account name, such as purely just "status"
let status_id: AccountId = "status".parse().unwrap();
let status_id: AccountId = ("status".to_string() + "." + contract.id().as_str())
.parse()
.unwrap();
let outcome = cross_contract_create_contract(&status_id, &status_amt, &contract).await?;
let failures = outcome.failures();
assert!(
failures.len() == 1,
failures.is_empty(),
"Expected one receipt failure for creating too short of a TLA, but got {} failures",
failures.len()
);

// Expect to succeed after calling into the contract with expected length for a
// top level account.
let status_id: AccountId = "status-top-level-account-long-name".parse().unwrap();
let outcome = cross_contract_create_contract(&status_id, &status_amt, &contract).await?;
let failures = outcome.failures();
assert!(
failures.is_empty(),
"Expected no failures for creating a TLA, but got {} failures",
failures.len(),
);

Ok(())
}

Expand All @@ -60,7 +51,9 @@ async fn test_cross_contract_calls() -> anyhow::Result<()> {
let contract = worker.dev_deploy(FACTORY_CONTRACT).await?;
let status_amt = NearToken::from_near(35);

let status_id: AccountId = "status-top-level-account-long-name".parse().unwrap();
let status_id: AccountId = ("status".to_string() + "." + contract.id().as_str())
.parse()
.unwrap();
cross_contract_create_contract(&status_id, &status_amt, &contract)
.await?
.into_result()?;
Expand Down

0 comments on commit 563f333

Please sign in to comment.