Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore/delete-account-test #289

Merged
merged 8 commits into from
Sep 9, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion workspaces/src/rpc/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ impl Client {
.await
}

// TODO: write tests that uses delete_account
pub(crate) async fn delete_account(
&self,
signer: &InMemorySigner,
Expand Down
30 changes: 30 additions & 0 deletions workspaces/tests/create_account.rs → workspaces/tests/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,33 @@ async fn test_subaccount_creation() -> anyhow::Result<()> {

Ok(())
}

#[test(tokio::test)]
async fn test_delete_account() -> anyhow::Result<()> {
let worker = workspaces::sandbox().await?;

let (alice, bob) = (
worker.dev_create_account().await?,
worker.dev_create_account().await?,
);

_ = alice.clone().delete_account(bob.id()).await?;

// All sandbox accounts start with a balance of `100 * 1_000_000_000_000_000_000_000_000` tokens.
// On account deletion, alice's balance is debited to bob as beneficiary.
assert!(bob.view_account().await?.balance > 100 * 1_900_000_000_000_000_000_000_000,);

// Alice's account should be deleted.
let res = alice.view_account().await;

assert!(res.is_err());

assert!(res
.unwrap_err()
.into_inner()
.unwrap()
.to_string()
.contains(&format!("{} does not exist while viewing", alice.id())),);

Ok(())
}