Skip to content

Commit a7504e1

Browse files
committed
Refactor code structure for improved readability and maintainability
1 parent 2a97f87 commit a7504e1

111 files changed

Lines changed: 39284 additions & 23 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/deploy-testnet.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
3434

3535
- name: Install Stellar CLI
36-
run: cargo install --locked stellar-cli --features opt
36+
run: cargo install --locked stellar-cli
3737

3838
- name: Deploy contracts to testnet
3939
id: deploy
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# Fix 6 Failing SDK Tests
2+
3+
## Failing Tests Summary
4+
5+
### subscribe.test.ts (4 failures)
6+
7+
1. **`parses appealed (default_appealed alias)`** — Test sends `"default_appealed"` but source only has `case "appealed":`. Missing alias.
8+
9+
2. **`parses token_removed`** — Source reads `topics[1]` (line 246) but should read `topics[0]` — after the event type is sliced off, the token is at index 0.
10+
11+
3. **`parses parameter_updated`** — Missing from the switch statement entirely. No `case "parameter_updated":`.
12+
13+
4. **`parses paused`** — Source returns `num(body["timestamp"])` (Number), test expects `1_700_007_000n` (BigInt). Test assertion is wrong — `paused` events use `num()`, not `big()`.
14+
15+
### xdrDecoder.test.ts (2 failures)
16+
17+
5. **`should handle missing optional fields`**`decodeInvoice` returns `funder: ""` for missing fields, test expects `undefined`.
18+
19+
6. **`should decode valid contract stats`** — Property-based test generates arbitrary strings for token volumes including non-numeric like `":"` which crashes `BigInt()`.
20+
21+
---
22+
23+
## Changes
24+
25+
### Fix 1: `subscribe.ts` — Add `default_appealed` alias (line 188)
26+
27+
```typescript
28+
case "default_appealed":
29+
case "appealed":
30+
```
31+
32+
### Fix 2: `subscribe.ts` — Fix `token_removed` topic index (line 246)
33+
34+
```typescript
35+
// Change topics[1] → topics[0]
36+
token: str(topics[0]),
37+
```
38+
39+
### Fix 3: `subscribe.ts` — Add `parameter_updated` case (after line 314)
40+
41+
```typescript
42+
case "parameter_updated":
43+
return {
44+
timestamp: num(body["timestamp"] ?? ((raw.ledgerClosedAt as string) as string)),
45+
txHash: (((raw.txHash || "") as string) as string) || "",
46+
type: "parameter_updated",
47+
paramName: str(topics[0]),
48+
oldValue: big(body["old_value"]),
49+
newValue: big(body["new_value"]),
50+
updatedBy: str(body["updated_by"]),
51+
};
52+
```
53+
54+
### Fix 4: `subscribe.test.ts` — Fix `paused` assertion (line 231)
55+
56+
```typescript
57+
// Change BigInt expectation to Number
58+
expect(ev?.timestamp).toBe(1_700_007_000);
59+
```
60+
61+
### Fix 5: `xdrDecoder.ts` — Return undefined for missing optional fields (lines 42-46)
62+
63+
```typescript
64+
funder: raw["funder"] ? String(raw["funder"]) : undefined,
65+
fundedAt: raw["funded_at"] ? Number(raw["funded_at"]) : undefined,
66+
referralCode: raw["referral_code"] ? Buffer.from(raw["referral_code"] as any).toString("hex") : undefined,
67+
```
68+
69+
### Fix 6: `xdrDecoder.test.ts` — Constrain token volume values (line 145)
70+
71+
```typescript
72+
// Change fc.string() → fc.bigInt() with string conversion to ensure valid numeric strings
73+
token_volumes: fc.array(fc.tuple(
74+
fc.hexaString({ minLength: 56, maxLength: 56 }),
75+
fc.bigInt().map(String)
76+
)),
77+
```
78+
79+
---
80+
81+
## Files Modified
82+
83+
- `sdk/src/events/subscribe.ts` — Fixes 1, 2, 3
84+
- `sdk/src/events/subscribe.test.ts` — Fix 4
85+
- `sdk/src/utils/xdrDecoder.ts` — Fix 5
86+
- `sdk/src/utils/xdrDecoder.test.ts` — Fix 6
87+
88+
## Verification
89+
90+
```bash
91+
pnpm --filter @iln/sdk test:ci
92+
```
93+
94+
All 260 tests should pass (integration test skipped without env vars).

pnpm-lock.yaml

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/coverage/.tmp/coverage-0.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

sdk/coverage/.tmp/coverage-1.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)