Skip to content
Merged
45 changes: 42 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,23 @@ jobs:
run: npm run build

integration-tests:
name: "Integration Tests"
name: Integration Tests (${{ matrix.name }})
runs-on: ubuntu-latest
needs: build

env:
ORACLE_TESTS: "DIDModule|DID Key Operations|OracleModule|ResourceModule"

strategy:
fail-fast: false
matrix:
include:
- name: esm
test_directory: esm

- name: cjs
test_directory: cjs

steps:
- uses: actions/checkout@v5

Expand All @@ -55,8 +68,34 @@ jobs:
- name: "Clean install dependencies"
run: npm ci

- name: Run Tests
run: npm test
- name: Run oracle independent tests
working-directory: ${{ matrix.test_directory }}
run: npm run test -- --testNamePattern="^(?!${ORACLE_TESTS})"

- name: Wait for WMA calculation
working-directory: localnet
shell: bash
run: |
set -euo pipefail

WAIT_TIME=240 # seconds
INTERVAL=20

echo "Waiting for WMA to be available..."

while ! docker compose exec cheqd cheqd-noded q oracle wma CHEQ >/dev/null 2>&1; do
if [ "$WAIT_TIME" -le 0 ]; then
echo "Unable to compute WMA within timeout"
exit 1
fi

sleep "$INTERVAL"
WAIT_TIME=$((WAIT_TIME - INTERVAL))
done

- name: Run oracle dependent tests
working-directory: ${{ matrix.test_directory }}
run: npm run test -- --testNamePattern="(${ORACLE_TESTS})"

import-tests:
name: "Import Tests"
Expand Down
64 changes: 48 additions & 16 deletions cjs/tests/modules/did.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,9 @@ describe('DIDModule', () => {
assertionMethod: [didPayload.verificationMethod![0].id], // <-- This is the only difference
} as DIDDocument;

const feeUpdate = await didModule.generateUpdateDidDocFees(feePayer);
const feeUpdate = await didModule.generateUpdateDidDocFees(feePayer, undefined, {
slippageBps: 1000,
});
const updateDidDocTx: DeliverTxResponse = await didModule.updateDidDocTx(
signInputs,
updateDidPayload,
Expand Down Expand Up @@ -593,7 +595,9 @@ describe('DIDModule', () => {
assertionMethod: [didPayload.verificationMethod![0].id], // <-- This is the only difference
} as DIDDocument;

const feeUpdate = await didModule.generateUpdateDidDocFees(feePayer);
const feeUpdate = await didModule.generateUpdateDidDocFees(feePayer, undefined, {
slippageBps: 1000,
});

const updateDidDocTx: DeliverTxResponse = await didModule.updateDidDocTx(
signInputs,
Expand Down Expand Up @@ -658,7 +662,9 @@ describe('DIDModule', () => {
assertionMethod: [didPayload.verificationMethod![0].id], // <-- This is the only difference
} as DIDDocument;

const feeUpdate = await didModule.generateUpdateDidDocFees(feePayer);
const feeUpdate = await didModule.generateUpdateDidDocFees(feePayer, undefined, {
slippageBps: 1000,
});

const updateDidDocTx: DeliverTxResponse = await didModule.updateDidDocTx(
signInputs,
Expand Down Expand Up @@ -759,7 +765,9 @@ describe('DIDModule', () => {
},
];

const updateFee = await didModule.generateUpdateDidDocFees(feePayer);
const updateFee = await didModule.generateUpdateDidDocFees(feePayer, undefined, {
slippageBps: 1000,
});
console.warn(`Updated DID payload: ${JSON.stringify(updatedDidPayload)}`);
const updateDidDocTx: DeliverTxResponse = await didModule.updateDidDocTx(
updateSignInputs,
Expand Down Expand Up @@ -872,7 +880,9 @@ describe('DIDModule', () => {
},
];

const updateFee = await didModule.generateUpdateDidDocFees(feePayer);
const updateFee = await didModule.generateUpdateDidDocFees(feePayer, undefined, {
slippageBps: 1000,
});
console.warn(`Updated DID payload: ${JSON.stringify(updatedDidPayload)}`);
const updateDidDocTx: DeliverTxResponse = await didModule.updateDidDocTx(
updateSignInputs,
Expand Down Expand Up @@ -920,7 +930,9 @@ describe('DIDModule', () => {
},
];

const finalUpdateFee = await didModule.generateUpdateDidDocFees(feePayer);
const finalUpdateFee = await didModule.generateUpdateDidDocFees(feePayer, undefined, {
slippageBps: 1000,
});
const finalUpdateDidDocTx: DeliverTxResponse = await didModule.updateDidDocTx(
finalSignInputs,
finalDidPayload,
Expand Down Expand Up @@ -1139,7 +1151,9 @@ describe('DIDModule', () => {
// Need signatures from both DID A and DID B
const combinedSignInputs = [...signInputsA, ...signInputsB];

const feeUpdate = await didModuleA.generateUpdateDidDocFees(feePayer);
const feeUpdate = await didModuleA.generateUpdateDidDocFees(feePayer, undefined, {
slippageBps: 1000,
});
const updateTx = await didModuleA.updateDidDocTx(
combinedSignInputs,
updatedDidPayloadA,
Expand Down Expand Up @@ -1171,7 +1185,9 @@ describe('DIDModule', () => {
// Need signatures from both current controllers (A and B)
const combinedSignInputs = [...signInputsA, ...signInputsB];

const feeUpdate = await didModuleA.generateUpdateDidDocFees(feePayer);
const feeUpdate = await didModuleA.generateUpdateDidDocFees(feePayer, undefined, {
slippageBps: 1000,
});
const updateTx = await didModuleA.updateDidDocTx(
combinedSignInputs,
updatedDidPayloadA,
Expand Down Expand Up @@ -1203,7 +1219,9 @@ describe('DIDModule', () => {
// Need signatures from current controller (B) and new controller (C)
const combinedSignInputs = [...signInputsB, ...signInputsC];

const feeUpdate = await didModuleA.generateUpdateDidDocFees(feePayer);
const feeUpdate = await didModuleA.generateUpdateDidDocFees(feePayer, undefined, {
slippageBps: 1000,
});
const updateTx = await didModuleA.updateDidDocTx(
combinedSignInputs,
updatedDidPayloadA,
Expand Down Expand Up @@ -1235,7 +1253,9 @@ describe('DIDModule', () => {
// Need signatures from current controller (C) and new controller (B)
const combinedSignInputs = [...signInputsB, ...signInputsC];

const feeUpdate = await didModuleA.generateUpdateDidDocFees(feePayer);
const feeUpdate = await didModuleA.generateUpdateDidDocFees(feePayer, undefined, {
slippageBps: 1000,
});
const updateTx = await didModuleA.updateDidDocTx(
combinedSignInputs,
updatedDidPayloadA,
Expand Down Expand Up @@ -1267,7 +1287,9 @@ describe('DIDModule', () => {
// Need signatures from current controllers (B and C) and the DID itself (A)
const combinedSignInputs = [...signInputsA, ...signInputsB, ...signInputsC];

const feeUpdate = await didModuleA.generateUpdateDidDocFees(feePayer);
const feeUpdate = await didModuleA.generateUpdateDidDocFees(feePayer, undefined, {
slippageBps: 1000,
});
const updateTx = await didModuleA.updateDidDocTx(
combinedSignInputs,
updatedDidPayloadA,
Expand Down Expand Up @@ -1298,7 +1320,9 @@ describe('DIDModule', () => {
// Only provide signature from DID A, missing signature from DID B
const incompleteSignInputs = [...signInputsA]; // Missing signInputsB

const feeUpdate = await didModuleA.generateUpdateDidDocFees(feePayer);
const feeUpdate = await didModuleA.generateUpdateDidDocFees(feePayer, undefined, {
slippageBps: 1000,
});

// This should fail due to missing signature
const updateTx = await didModuleA.updateDidDocTx(
Expand Down Expand Up @@ -1331,7 +1355,9 @@ describe('DIDModule', () => {
// Need signatures from both current controller (A) and new controller (B)
const combinedSignInputs = [...signInputsA, ...signInputsB];

const feeUpdate = await didModuleA.generateUpdateDidDocFees(feePayer);
const feeUpdate = await didModuleA.generateUpdateDidDocFees(feePayer, undefined, {
slippageBps: 1000,
});
const updateTx = await didModuleA.updateDidDocTx(
combinedSignInputs,
updatedDidPayloadA,
Expand Down Expand Up @@ -1974,7 +2000,9 @@ describe('DIDModule', () => {
assertionMethod: [didPayload.verificationMethod![0].id], // <-- This is the only difference
} as DIDDocument;

const feeUpdate = await didModule.generateUpdateDidDocFees(feePayer);
const feeUpdate = await didModule.generateUpdateDidDocFees(feePayer, undefined, {
slippageBps: 1000,
});
const updateDidDocTx: DeliverTxResponse = await didModule.updateDidDocTx(
signInputs,
updateDidPayload,
Expand Down Expand Up @@ -2075,7 +2103,9 @@ describe('DIDModule', () => {
assertionMethod: [didPayload.verificationMethod![0].id], // <-- This is the only difference
} as DIDDocument;

const feeUpdate = await didModule.generateUpdateDidDocFees(feePayer);
const feeUpdate = await didModule.generateUpdateDidDocFees(feePayer, undefined, {
slippageBps: 1000,
});
const updateDidDocTx: DeliverTxResponse = await didModule.updateDidDocTx(
signInputs,
updateDidPayload,
Expand Down Expand Up @@ -2176,7 +2206,9 @@ describe('DIDModule', () => {
assertionMethod: [didPayload.verificationMethod![0].id], // <-- This is the only difference
} as DIDDocument;

const feeUpdate = await didModule.generateUpdateDidDocFees(feePayer);
const feeUpdate = await didModule.generateUpdateDidDocFees(feePayer, undefined, {
slippageBps: 1000,
});
const updateDidDocTx: DeliverTxResponse = await didModule.updateDidDocTx(
signInputs,
updateDidPayload,
Expand Down
24 changes: 18 additions & 6 deletions cjs/tests/modules/key-operations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ describe('DID Key Operations (Rotation, Replacement, and Combined)', () => {

const combinedSignInputs = [...signInputs1, ...signInputs2]; // Both old and new key signatures

const feeUpdate = await didModule.generateUpdateDidDocFees(feePayer);
const feeUpdate = await didModule.generateUpdateDidDocFees(feePayer, undefined, {
slippageBps: 1000,
});
const updateTx = await didModule.updateDidDocTx(
combinedSignInputs,
rotatedDidPayload,
Expand Down Expand Up @@ -261,7 +263,9 @@ describe('DID Key Operations (Rotation, Replacement, and Combined)', () => {
expect(combinedSignInputs[0].verificationMethodId).toBe(verificationKeys1.keyId);
expect(combinedSignInputs[1].verificationMethodId).toBe(verificationKeys2WithSameDid.keyId);

const feeUpdate = await didModule.generateUpdateDidDocFees(feePayer);
const feeUpdate = await didModule.generateUpdateDidDocFees(feePayer, undefined, {
slippageBps: 1000,
});
const updateTx = await didModule.updateDidDocTx(
combinedSignInputs,
replacedDidPayload,
Expand Down Expand Up @@ -406,7 +410,9 @@ describe('DID Key Operations (Rotation, Replacement, and Combined)', () => {

const combinedSignInputs = [...signInputs1, ...signInputs2];

const feeUpdate = await didModule.generateUpdateDidDocFees(feePayer);
const feeUpdate = await didModule.generateUpdateDidDocFees(feePayer, undefined, {
slippageBps: 1000,
});
const updateTx = await didModule.updateDidDocTx(
combinedSignInputs,
expandedDidPayload,
Expand Down Expand Up @@ -567,7 +573,9 @@ describe('DID Key Operations (Rotation, Replacement, and Combined)', () => {
];

// Step 4: Execute the combined operation
const feeUpdate = await didModule.generateUpdateDidDocFees(feePayer);
const feeUpdate = await didModule.generateUpdateDidDocFees(feePayer, undefined, {
slippageBps: 1000,
});
const updateTx = await didModule.updateDidDocTx(
combinedSignInputs,
updatedDidPayload,
Expand Down Expand Up @@ -1003,7 +1011,9 @@ describe('DID Key Operations (Rotation, Replacement, and Combined)', () => {
},
];

const feeUpdate = await didModule.generateUpdateDidDocFees(feePayer);
const feeUpdate = await didModule.generateUpdateDidDocFees(feePayer, undefined, {
slippageBps: 1000,
});

await expect(
didModule.updateDidDocTx(invalidSignInputs, updatedDidPayload, feePayer, feeUpdate)
Expand Down Expand Up @@ -1096,7 +1106,9 @@ describe('DID Key Operations (Rotation, Replacement, and Combined)', () => {
},
];

const feeUpdate = await didModule.generateUpdateDidDocFees(feePayer);
const feeUpdate = await didModule.generateUpdateDidDocFees(feePayer, undefined, {
slippageBps: 1000,
});

await expect(
didModule.updateDidDocTx(invalidSignInputs, updatedDidPayload, feePayer, feeUpdate)
Expand Down
2 changes: 1 addition & 1 deletion cjs/tests/testutils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const faucet = {
export const localnet = {
network: CheqdNetwork.Testnet,
testnetRpcUrl: 'https://rpc.cheqd.network:443',
rpcUrl: 'https://rpc-devnet.cheqd.network:443',
rpcUrl: 'http://localhost:26657',
gasPrice: GasPrice.fromString(`5000${faucet.minimalDenom}`),
};

Expand Down
Loading