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 35281bb
Showing 1 changed file with 7 additions and 14 deletions.
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 35281bb

Please sign in to comment.