Skip to content

Commit

Permalink
#952 File not saved after CREATE2 verification
Browse files Browse the repository at this point in the history
* the store function was not present in the create2 verification
* add tests to check the existence of the contract in create2 tests
  • Loading branch information
marcocastignoli authored and kuzdogan committed Mar 9, 2023
1 parent 92b65d3 commit b64da92
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 6 deletions.
13 changes: 11 additions & 2 deletions src/server/controllers/VerificationController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -449,14 +449,19 @@ export default class VerificationController

const contract: CheckedContract = checkedContracts[0];

const result = await verifyCreate2(
const match = await verifyCreate2(
contract,
deployerAddress,
salt,
create2Address,
abiEncodedConstructorArguments
);
res.send({ result: [result] });

if (match.status) {
await this.repositoryService.storeMatch(contract, match);
}

res.send({ result: [match] });
};

private sessionVerifyCreate2 = async (
Expand Down Expand Up @@ -498,6 +503,10 @@ export default class VerificationController
contractWrapper.storageTimestamp = match.storageTimestamp;
contractWrapper.address = match.address;

if (match.status) {
await this.repositoryService.storeMatch(contract, match);
}

res.send(getSessionJSON(session));
};

Expand Down
32 changes: 28 additions & 4 deletions test/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,16 +356,28 @@ describe("Server", function () {
.post("/session/verify/create2")
.send({
deployerAddress: "0xd9145CCE52D386f254917e481eB44e9943F39138",
salt: 12345,
salt: 12344,
abiEncodedConstructorArguments:
"0x0000000000000000000000005b38da6a701c568545dcfcb03fcb875f56beddc40000000000000000000000005b38da6a701c568545dcfcb03fcb875f56beddc4",
clientToken: clientToken || "",
create2Address: "0x801B9c0Ee599C3E5ED60e4Ec285C95fC9878Ee64",
create2Address: "0x65790cc291a234eDCD6F28e1F37B036eD4F01e3B",
verificationId: verificationId,
})
.end((err, res) => {
assertAllFound(err, res, "perfect");
done();
chai
.request(server.app)
.get("/check-all-by-addresses")
.query({
chainIds: "0",
addresses: ["0x65790cc291a234eDCD6F28e1F37B036eD4F01e3B"],
})
.end((err, res) => {
chai.expect(err).to.be.null;
chai.expect(res.body).to.have.a.lengthOf(1);
chai.expect(res.body[0].chainIds).to.have.a.lengthOf(1);
done();
});
});
});

Expand Down Expand Up @@ -399,7 +411,19 @@ describe("Server", function () {
})
.end((err, res) => {
assertAPIAllFound(err, res, "perfect");
done();
chai
.request(server.app)
.get("/check-all-by-addresses")
.query({
chainIds: "0",
addresses: ["0x801B9c0Ee599C3E5ED60e4Ec285C95fC9878Ee64"],
})
.end((err, res) => {
chai.expect(err).to.be.null;
chai.expect(res.body).to.have.a.lengthOf(1);
chai.expect(res.body[0].chainIds).to.have.a.lengthOf(1);
done();
});
});
});
});
Expand Down

0 comments on commit b64da92

Please sign in to comment.