Skip to content

feat: add escrow contract test for concurrent initialize attempts (re-entrancy guard) #309

Description

@Dami24-hub

Summary

The escrow contract guards against double-initialization with AlreadyInitialized. However, there is no test that verifies this guard works correctly when initialize() is called twice in quick succession, simulating a race condition in a test environment.

File

contracts/escrow/src/test.rs

Expected fix

Add a test:

#[test]
#[should_panic(expected = "AlreadyInitialized")]
fn test_double_initialize_panics() {
    // ... setup ...
    client.initialize(&depositor, &recipient, &arbiter, &token, &amount, &expiry);
    client.initialize(&depositor, &recipient, &arbiter, &token, &amount, &expiry); // should panic
}

Acceptance criteria

  • Test exists and passes with cargo test
  • Guard is verified to fire on second call

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions