Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zoeyTM committed May 3, 2024
1 parent 6ceae94 commit 99b6af3
Show file tree
Hide file tree
Showing 3 changed files with 207 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,89 @@ describe("Reconciliation - named contract call", () => {
]);
});

it("should reconcile an address arg with entirely different casing", async () => {
const moduleDefinition = buildModule("Module", (m) => {
const contract1 = m.contract("Contract1");

m.call(
contract1,
"function1",
["0x15d34aaf54267db7d7c367839aaf71a00a2c6a65"],
{}
);

return { contract1 };
});

await assertSuccessReconciliation(
moduleDefinition,
createDeploymentState(
{
...exampleDeploymentState,
id: "Module#Contract1",
status: ExecutionStatus.SUCCESS,
result: {
type: ExecutionResultType.SUCCESS,
address: differentAddress,
},
},
{
...exampleContractCallState,
id: "Module#Contract1.function1",
futureType: FutureType.CONTRACT_CALL,
status: ExecutionStatus.STARTED,
functionName: "function1",
args: ["0x15D34AAF54267DB7D7C367839AAF71A00A2C6A65"],
}
)
);
});

it("should fail to reconcile an address arg with partially different casing", async () => {
const moduleDefinition = buildModule("Module", (m) => {
const contract1 = m.contract("Contract1");

m.call(
contract1,
"function1",
["0x15d34aaf54267db7d7c367839aaf71a00a2c6a65"],
{}
);

return { contract1 };
});

const reconiliationResult = await reconcile(
moduleDefinition,
createDeploymentState(
{
...exampleDeploymentState,
id: "Module#Contract1",
status: ExecutionStatus.SUCCESS,
result: {
type: ExecutionResultType.SUCCESS,
address: differentAddress,
},
},
{
...exampleContractCallState,
id: "Module#Contract1.function1",
futureType: FutureType.CONTRACT_CALL,
status: ExecutionStatus.STARTED,
functionName: "function1",
args: ["0x15d34aaf54267db7D7c367839aaf71a00a2c6a65"],
}
)
);

assert.deepStrictEqual(reconiliationResult.reconciliationFailures, [
{
futureId: "Module#Contract1.function1",
failure: "Argument at index 0 has been changed",
},
]);
});

it("should find changes to value unreconciliable", async () => {
const moduleDefinition = buildModule("Module", (m) => {
const contract1 = m.contract("Contract1");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,53 @@ describe("Reconciliation - named contract", () => {
]);
});

it("should reconcile an address arg with entirely different casing", async () => {
const moduleDefinition = buildModule("Module", (m) => {
const contract1 = m.contract("Contract1", [
"0x15d34aaf54267db7d7c367839aaf71a00a2c6a65",
]);

return { contract1 };
});

await assertSuccessReconciliation(
moduleDefinition,
createDeploymentState({
...exampleDeploymentState,
id: "Module#Contract1",
status: ExecutionStatus.STARTED,
constructorArgs: ["0x15D34AAF54267DB7D7C367839AAF71A00A2C6A65"],
})
);
});

it("should fail to reconcile an address arg with partially different casing", async () => {
const moduleDefinition = buildModule("Module", (m) => {
const contract1 = m.contract("Contract1", [
"0x15d34aaf54267db7d7c367839aaf71a00a2c6a65",
]);

return { contract1 };
});

const reconciliationResult = await reconcile(
moduleDefinition,
createDeploymentState({
...exampleDeploymentState,
id: "Module#Contract1",
status: ExecutionStatus.STARTED,
constructorArgs: ["0x15d34aaf54267db7D7c367839aaf71a00a2c6a65"],
})
);

assert.deepStrictEqual(reconciliationResult.reconciliationFailures, [
{
futureId: "Module#Contract1",
failure: "Argument at index 0 has been changed",
},
]);
});

it("should find changes to libraries unreconciliable", async () => {
const moduleDefinition = buildModule("Module", (m) => {
const safeMath = m.library("SafeMath");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,83 @@ describe("Reconciliation - named static call", () => {
]);
});

it("should reconcile an address arg with entirely different casing", async () => {
const moduleDefinition = buildModule("Module", (m) => {
const contract1 = m.contract("Contract1");

m.staticCall(contract1, "function1", [
"0x15d34aaf54267db7d7c367839aaf71a00a2c6a65",
]);

return { contract1 };
});

await assertSuccessReconciliation(
moduleDefinition,
createDeploymentState(
{
...exampleDeploymentState,
id: "Module#Contract1",
status: ExecutionStatus.SUCCESS,
result: {
type: ExecutionResultType.SUCCESS,
address: exampleAddress,
},
},
{
...exampleStaticCallState,
id: "Module#Contract1.function1",
futureType: FutureType.STATIC_CALL,
status: ExecutionStatus.STARTED,
functionName: "function1",
args: ["0x15D34AAF54267DB7D7C367839AAF71A00A2C6A65"],
}
)
);
});

it("should fail to reconcile an address arg with partially different casing", async () => {
const moduleDefinition = buildModule("Module", (m) => {
const contract1 = m.contract("Contract1");

m.staticCall(contract1, "function1", [
"0x15d34aaf54267db7d7c367839aaf71a00a2c6a65",
]);

return { contract1 };
});

const reconiliationResult = await reconcile(
moduleDefinition,
createDeploymentState(
{
...exampleDeploymentState,
id: "Module#Contract1",
status: ExecutionStatus.SUCCESS,
result: {
type: ExecutionResultType.SUCCESS,
address: exampleAddress,
},
},
{
...exampleStaticCallState,
id: "Module#Contract1.function1",
futureType: FutureType.STATIC_CALL,
status: ExecutionStatus.STARTED,
functionName: "function1",
args: ["0x15d34aaf54267db7D7c367839aaf71a00a2c6a65"],
}
)
);

assert.deepStrictEqual(reconiliationResult.reconciliationFailures, [
{
futureId: "Module#Contract1.function1",
failure: "Argument at index 0 has been changed",
},
]);
});

it("should find changes to from unreconciliable", async () => {
const moduleDefinition = buildModule("Module", (m) => {
const contract1 = m.contract("Contract1");
Expand Down

0 comments on commit 99b6af3

Please sign in to comment.