Skip to content

Commit b7cb572

Browse files
committed
Fix stale audit row, add refund test, run cargo doc in CI, commit npm lockfile
Closes #170, closes #174, closes #173, closes #167 - docs/access-control-audit.md: correct the refund permissionless-window row, which said the deliberate no-auth path opens "at/after deadline"; it actually opens at deadline + GRACE_PERIOD since #49 introduced the 14-day grace period to stop a sponsor from racing permissionless refund() against an already-processed release(). Cross-referenced #49. - contracts/escrow/src/test.rs: add test_contribute_rejects_after_already_refunded, mirroring test_contribute_rejects_after_already_paid, covering the AlreadyRefunded branch of contribute()'s status check that had no test. - .github/workflows/ci.yml: run cargo doc --workspace --no-deps --document-private-items with RUSTDOCFLAGS=-D warnings so broken intra-doc links or malformed doc comments fail CI instead of only being caught by chance. - .gitignore / package-lock.json: stop ignoring package-lock.json and commit it so @stellar/stellar-sdk's resolved dependency tree (used by scripts/deploy.mjs, which deployed the live testnet contracts) is reproducible across machines, matching the reproducibility guarantee Cargo.lock already gives the Rust side.
1 parent f4abb98 commit b7cb572

5 files changed

Lines changed: 587 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ jobs:
2525
- run: cargo clippy --workspace --all-targets -- -D warnings
2626
- run: cargo test --workspace
2727

28+
- name: Check documentation (catches broken intra-doc links)
29+
env:
30+
RUSTDOCFLAGS: "-D warnings"
31+
run: cargo doc --workspace --no-deps --document-private-items
32+
2833
- name: Generate and print code coverage
2934
run: cargo llvm-cov --workspace
3035

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,3 @@ test_snapshots/
2424

2525
# deploy script dependencies (scripts/)
2626
node_modules/
27-
package-lock.json

contracts/escrow/src/test.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,29 @@ fn test_contribute_rejects_after_already_paid() {
743743
assert_eq!(err, Err(Ok(Error::AlreadyPaid)));
744744
}
745745

746+
#[test]
747+
fn test_contribute_rejects_after_already_refunded() {
748+
let env = Env::default();
749+
env.mock_all_auths();
750+
let (_, _admin, _treasury, client) = setup(&env);
751+
752+
let token_admin = Address::generate(&env);
753+
let (token_addr, asset_client, _token_client) = create_token(&env, &token_admin);
754+
let alice = Address::generate(&env);
755+
let bob = Address::generate(&env);
756+
asset_client.mint(&alice, &10_000i128);
757+
asset_client.mint(&bob, &10_000i128);
758+
759+
env.ledger().set_timestamp(100);
760+
client.fund(&106u64, &alice, &token_addr, &5_000i128, &200u64, &None);
761+
762+
env.ledger().set_timestamp(200 + crate::GRACE_PERIOD);
763+
client.refund(&106u64);
764+
765+
let err = client.try_contribute(&106u64, &bob, &1_000i128);
766+
assert_eq!(err, Err(Ok(Error::AlreadyRefunded)));
767+
}
768+
746769
#[test]
747770
fn test_contribute_rejects_beyond_max_sponsors() {
748771
let env = Env::default();

docs/access-control-audit.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ signature requirement on any particular address.
1717
| `initialize` | Deployer/authorized setup only (implicit — not written down anywhere) | none | `admin.require_auth()` | **Mismatch, fixed** — see "`initialize` has no access control" below |
1818
| `fund` | Sponsor-only | `sponsor.require_auth()` | unchanged | Match |
1919
| `release` | Admin-only | `require_admin(&env)?.require_auth()` | unchanged | Match |
20-
| `refund` (before `deadline`) | Admin-only | `require_admin(&env)?.require_auth()` | unchanged | Match |
21-
| `refund` (at/after `deadline`) | Permissionless (deliberate) | none | unchanged | Match — see [refund analysis](./refund-permissionless-analysis.md) |
20+
| `refund` (before `deadline + GRACE_PERIOD`) | Admin-only | `require_admin(&env)?.require_auth()` | unchanged | Match |
21+
| `refund` (at/after `deadline + GRACE_PERIOD`) | Permissionless (deliberate) | none | unchanged | Match — see [refund analysis](./refund-permissionless-analysis.md). The permissionless window opens at `deadline + GRACE_PERIOD`, not at `deadline` itself; the 14-day `GRACE_PERIOD` was introduced by [#49](https://github.com/MergeFi/contracts/issues/49) to close a race where a sponsor could call permissionless `refund()` right at `deadline` to claw back funds from a contributor whose `release()` had already landed. |
2222
| `extend_deadline` (new, this PR) | Sponsor-only, monotonic | n/a | `escrow.sponsor.require_auth()` + `new_deadline` must strictly increase | Match (new function) |
2323
| `get_escrow` | Permissionless (view) | none | unchanged | Match |
2424
| `get_admin` | Permissionless (view) | none | unchanged | Match |

0 commit comments

Comments
 (0)