Skip to content

Commit

Permalink
Updating tests and updates from tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AvbrehtLuka committed Dec 12, 2024
1 parent fbc41f6 commit 906a046
Show file tree
Hide file tree
Showing 27 changed files with 3,832 additions and 2,939 deletions.
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,27 @@ $ yarn run test:cov

## Testing with postgresql dump

TODO
Get DB instances from some persistent storage, or ask other devs

Move those db dumps to /e2e_tests/db/

set .env, you will need to specify the right value for `VERIFIER_TYPE` and `TESTNET` variables
for now all dbs are on testnets, so provide `TESTNET=true`

### option1: running tests against db instance

depending on your source, use the following command (btc example)
```yarn test:btc```

### option2: spinning up db from dumpb and persist it

again depending on your sourrce create db instance
```yarn test:make_db:btc```
after that db will be available and you can
1. run tests against it, to do so use `yarn test:run_tests:btc`
2. start up local server and make requests by hand

After you are done make sure to stop the db server with
```yarn test:delete_db```


Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe("/ConfirmedBlockHeightExists/verifyFDC", () => {
});
it("should get bad request (400) with non hexadecimal character in abiEncodedRequest", async () => {
const payload = {
abiEncodedRequest: "0x436f6e6669726d6564426c6f636b4865696768744578697374730000000000007465737442544300000000000000000000000000000000000000000000000000278ad8cc684365d1f1b0ac2e4d893ef2d604cd76f6dacdf96d13f7f37984b2a5000000000000000000000000000000000000000000000000000000000035416c0000000000000000000000000000000000000000000000000000000000000001",
abiEncodedRequest: "0xp36f6e6669726d6564426c6f636b4865696768744578697374730000000000007465737442544300000000000000000000000000000000000000000000000000278ad8cc684365d1f1b0ac2e4d893ef2d604cd76f6dacdf96d13f7f37984b2a5000000000000000000000000000000000000000000000000000000000035416c0000000000000000000000000000000000000000000000000000000000000001",
}
await request(app.getHttpServer())
.post("/ConfirmedBlockHeightExists/verifyFDC")
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,76 +1,67 @@
import { expect } from "chai";
import * as request from "supertest";
import { app } from "../helper";


describe("/ReferencedPaymentNonexistence/verifyFDC", () => {
it("should get status", async () => {
const payload = {
abiEncodedRequest: "0x5265666572656e6365645061796d656e744e6f6e6578697374656e6365000000746573744254430000000000000000000000000000000000000000000000000082397886cabdaf4b939554abd5c36dbcb2607d3af32f6e1ad8bdba4a368ba6ec0000000000000000000000000000000000000000000000000000000000354167000000000000000000000000000000000000000000000000000000000035416a0000000000000000000000000000000000000000000000000000000067481f7910b66af8f7bb2f450482037671e44a90ebcaf13e032108d3e8e82b9ec13bfc3700000000000000000000000000000000000000000000000000000000004e86c600000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001cb59478070fabf8aef96f6ff20a05abb8e922601cd24f13a4fc876b35fa62feb"
}
const response = await request(app.getHttpServer())
.post("/ReferencedPaymentNonexistence/verifyFDC")
.send(payload)
.set('X-API-KEY', '12345')
.expect(200)
.expect('Content-Type', /json/)

expect(response.body.status).to.be.equal('VALID');
});
it("should get abiEncodedResponse without 0x in abiEncodedRequest", async () => {
const payload = {
abiEncodedRequest: "5265666572656e6365645061796d656e744e6f6e6578697374656e6365000000746573744254430000000000000000000000000000000000000000000000000082397886cabdaf4b939554abd5c36dbcb2607d3af32f6e1ad8bdba4a368ba6ec0000000000000000000000000000000000000000000000000000000000354167000000000000000000000000000000000000000000000000000000000035416a0000000000000000000000000000000000000000000000000000000067481f7910b66af8f7bb2f450482037671e44a90ebcaf13e032108d3e8e82b9ec13bfc3700000000000000000000000000000000000000000000000000000000004e86c600000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001cb59478070fabf8aef96f6ff20a05abb8e922601cd24f13a4fc876b35fa62feb",
}
const response = await request(app.getHttpServer())
.post("/ReferencedPaymentNonexistence/verifyFDC")
.send(payload)
.set('X-API-KEY', '12345')
.expect(200)
.expect('Content-Type', /json/)

expect(response.body.status).to.be.equal('VALID');
});
it("should get abiEncodedResponse with 0X in abiEncodedRequest", async () => {
const payload = {
abiEncodedRequest: "0X5265666572656e6365645061796d656e744e6f6e6578697374656e6365000000746573744254430000000000000000000000000000000000000000000000000082397886cabdaf4b939554abd5c36dbcb2607d3af32f6e1ad8bdba4a368ba6ec0000000000000000000000000000000000000000000000000000000000354167000000000000000000000000000000000000000000000000000000000035416a0000000000000000000000000000000000000000000000000000000067481f7910b66af8f7bb2f450482037671e44a90ebcaf13e032108d3e8e82b9ec13bfc3700000000000000000000000000000000000000000000000000000000004e86c600000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001cb59478070fabf8aef96f6ff20a05abb8e922601cd24f13a4fc876b35fa62feb",
}
const response = await request(app.getHttpServer())
.post("/ReferencedPaymentNonexistence/verifyFDC")
.send(payload)
.set('X-API-KEY', '12345')
.expect(200)
.expect('Content-Type', /json/)

expect(response.body.status).to.be.equal('VALID');
});
it("should get bad request (400) with empty payload", async () => {
const payload = {
}
await request(app.getHttpServer())
.post("/ReferencedPaymentNonexistence/verifyFDC")
.send(payload)
.set('X-API-KEY', '12345')
.expect(400)
});
it("should get bad request (400) with non hexadecimal character in abiEncodedRequest", async () => {
const payload = {
abiEncodedRequest: "0xy265666572656e6365645061796d656e744e6f6e6578697374656e6365000000746573744254430000000000000000000000000000000000000000000000000082397886cabdaf4b939554abd5c36dbcb2607d3af32f6e1ad8bdba4a368ba6ec0000000000000000000000000000000000000000000000000000000000354167000000000000000000000000000000000000000000000000000000000035416a0000000000000000000000000000000000000000000000000000000067481f7910b66af8f7bb2f450482037671e44a90ebcaf13e032108d3e8e82b9ec13bfc3700000000000000000000000000000000000000000000000000000000004e86c600000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001cb59478070fabf8aef96f6ff20a05abb8e922601cd24f13a4fc876b35fa62feb",
}
await request(app.getHttpServer())
.post("/ReferencedPaymentNonexistence/verifyFDC")
.send(payload)
.set('X-API-KEY', '12345')
.expect(400)
});
import { expect } from 'chai';
import * as request from 'supertest';
import { app } from '../helper';

describe('/ReferencedPaymentNonexistence/verifyFDC', () => {
it('should get status', async () => {
const payload = {
abiEncodedRequest:
'0x5265666572656e6365645061796d656e744e6f6e6578697374656e6365000000746573744254430000000000000000000000000000000000000000000000000082397886cabdaf4b939554abd5c36dbcb2607d3af32f6e1ad8bdba4a368ba6ec0000000000000000000000000000000000000000000000000000000000354167000000000000000000000000000000000000000000000000000000000035416a0000000000000000000000000000000000000000000000000000000067481f7910b66af8f7bb2f450482037671e44a90ebcaf13e032108d3e8e82b9ec13bfc3700000000000000000000000000000000000000000000000000000000004e86c600000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001cb59478070fabf8aef96f6ff20a05abb8e922601cd24f13a4fc876b35fa62feb',
};
const response = await request(app.getHttpServer())
.post('/ReferencedPaymentNonexistence/verifyFDC')
.send(payload)
.set('X-API-KEY', '12345')
.expect(200)
.expect('Content-Type', /json/);

expect(response.body.status).to.be.equal('VALID');
});
it('should get abiEncodedResponse without 0x in abiEncodedRequest', async () => {
const payload = {
abiEncodedRequest:
'5265666572656e6365645061796d656e744e6f6e6578697374656e6365000000746573744254430000000000000000000000000000000000000000000000000082397886cabdaf4b939554abd5c36dbcb2607d3af32f6e1ad8bdba4a368ba6ec0000000000000000000000000000000000000000000000000000000000354167000000000000000000000000000000000000000000000000000000000035416a0000000000000000000000000000000000000000000000000000000067481f7910b66af8f7bb2f450482037671e44a90ebcaf13e032108d3e8e82b9ec13bfc3700000000000000000000000000000000000000000000000000000000004e86c600000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001cb59478070fabf8aef96f6ff20a05abb8e922601cd24f13a4fc876b35fa62feb',
};
const response = await request(app.getHttpServer())
.post('/ReferencedPaymentNonexistence/verifyFDC')
.send(payload)
.set('X-API-KEY', '12345')
.expect(200)
.expect('Content-Type', /json/);

expect(response.body.status).to.be.equal('VALID');
});
it('should get abiEncodedResponse with 0X in abiEncodedRequest', async () => {
const payload = {
abiEncodedRequest:
'0X5265666572656e6365645061796d656e744e6f6e6578697374656e6365000000746573744254430000000000000000000000000000000000000000000000000082397886cabdaf4b939554abd5c36dbcb2607d3af32f6e1ad8bdba4a368ba6ec0000000000000000000000000000000000000000000000000000000000354167000000000000000000000000000000000000000000000000000000000035416a0000000000000000000000000000000000000000000000000000000067481f7910b66af8f7bb2f450482037671e44a90ebcaf13e032108d3e8e82b9ec13bfc3700000000000000000000000000000000000000000000000000000000004e86c600000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001cb59478070fabf8aef96f6ff20a05abb8e922601cd24f13a4fc876b35fa62feb',
};
const response = await request(app.getHttpServer())
.post('/ReferencedPaymentNonexistence/verifyFDC')
.send(payload)
.set('X-API-KEY', '12345')
.expect(200)
.expect('Content-Type', /json/);

expect(response.body.status).to.be.equal('VALID');
});
it('should get bad request (400) with empty payload', async () => {
const payload = {};
await request(app.getHttpServer())
.post('/ReferencedPaymentNonexistence/verifyFDC')
.send(payload)
.set('X-API-KEY', '12345')
.expect(400);
});
it('should get bad request (400) with non hexadecimal character in abiEncodedRequest', async () => {
const payload = {
abiEncodedRequest:
'0xy265666572656e6365645061796d656e744e6f6e6578697374656e6365000000746573744254430000000000000000000000000000000000000000000000000082397886cabdaf4b939554abd5c36dbcb2607d3af32f6e1ad8bdba4a368ba6ec0000000000000000000000000000000000000000000000000000000000354167000000000000000000000000000000000000000000000000000000000035416a0000000000000000000000000000000000000000000000000000000067481f7910b66af8f7bb2f450482037671e44a90ebcaf13e032108d3e8e82b9ec13bfc3700000000000000000000000000000000000000000000000000000000004e86c600000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001cb59478070fabf8aef96f6ff20a05abb8e922601cd24f13a4fc876b35fa62feb',
};
await request(app.getHttpServer())
.post('/ReferencedPaymentNonexistence/verifyFDC')
.send(payload)
.set('X-API-KEY', '12345')
.expect(400);
});
});











Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe("/ReferencedPaymentNonexistence/mic", () => {
expect(response.body.status).to.be.equal('VALID');
expect(response.body.messageIntegrityCode.length).to.be.equal(66);
});
it("should get abiEncodedRequest with checkSourceAddresses=false and random sourceAddressesRoot", async () => {
it.skip("should get abiEncodedRequest with checkSourceAddresses=false and random sourceAddressesRoot", async () => {
const payload = {
attestationType: "0x5265666572656e6365645061796d656e744e6f6e6578697374656e6365000000",
sourceId: "0x74657374444f4745000000000000000000000000000000000000000000000000",
Expand All @@ -82,7 +82,7 @@ describe("/ReferencedPaymentNonexistence/mic", () => {
expect(response.body.status).to.be.equal('VALID');
expect(response.body.messageIntegrityCode.length).to.be.equal(66);
});
it("should get abiEncodedRequest with checkSourceAddresses=false and no sourceAddressesRoot", async () => {
it.skip("should get abiEncodedRequest with checkSourceAddresses=false and no sourceAddressesRoot", async () => {
const payload = {
attestationType: "0x5265666572656e6365645061796d656e744e6f6e6578697374656e6365000000",
sourceId: "0x74657374444f4745000000000000000000000000000000000000000000000000",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe("/ReferencedPaymentNonexistence/prepareRequest", () => {

expect(response.body.status).to.be.equal('VALID');
});
it("should get abiEncodedRequest with checkSourceAddresses=false and random sourceAddressesRoot", async () => {
it.skip("should get abiEncodedRequest with checkSourceAddresses=false and random sourceAddressesRoot", async () => {
const payload = {
attestationType: "0x5265666572656e6365645061796d656e744e6f6e6578697374656e6365000000",
sourceId: "0x74657374444f4745000000000000000000000000000000000000000000000000",
Expand All @@ -79,7 +79,7 @@ describe("/ReferencedPaymentNonexistence/prepareRequest", () => {

expect(response.body.status).to.be.equal('VALID');
});
it("should get abiEncodedRequest with checkSourceAddresses=false and no sourceAddressesRoot", async () => {
it.skip("should get abiEncodedRequest with checkSourceAddresses=false and no sourceAddressesRoot", async () => {
const payload = {
attestationType: "0x5265666572656e6365645061796d656e744e6f6e6578697374656e6365000000",
sourceId: "0x74657374444f4745000000000000000000000000000000000000000000000000",
Expand Down Expand Up @@ -741,7 +741,7 @@ describe("/ReferencedPaymentNonexistence/prepareRequest", () => {
sourceId: "0x74657374444f4745000000000000000000000000000000000000000000000000",
requestBody: {
minimalBlockNumber: "6724525",
deadlineBlockNumber: "6724602",
deadlineBlockNumber: "6724601",
deadlineTimestamp: "0",
destinationAddressHash: standardAddressHash("n24Juz7LGy3uFFuZBggLw1eH1E9G19JrbX"),
amount: "5146310",
Expand All @@ -766,7 +766,7 @@ describe("/ReferencedPaymentNonexistence/prepareRequest", () => {
requestBody: {
minimalBlockNumber: "6724525",
deadlineBlockNumber: "1",
deadlineTimestamp: "1732810420",
deadlineTimestamp: "1732810419",
destinationAddressHash: standardAddressHash("n24Juz7LGy3uFFuZBggLw1eH1E9G19JrbX"),
amount: "5146310",
standardPaymentReference: "0000000000000000000000000000000000000000000000000000000000000001",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe("/ReferencedPaymentNonexistence/prepareResponse", () => {
expect(response.body.response.responseBody.firstOverflowBlockTimestamp).to.be.equal('1732810325');

});
it("should get abiEncodedRequest with checkSourceAddresses=false and random sourceAddressesRoot", async () => {
it.skip("should get abiEncodedRequest with checkSourceAddresses=false and random sourceAddressesRoot", async () => {
const payload = {
attestationType: "0x5265666572656e6365645061796d656e744e6f6e6578697374656e6365000000",
sourceId: "0x74657374444f4745000000000000000000000000000000000000000000000000",
Expand Down Expand Up @@ -111,7 +111,7 @@ describe("/ReferencedPaymentNonexistence/prepareResponse", () => {
expect(response.body.response.responseBody.firstOverflowBlockTimestamp).to.be.equal('1732810325');

});
it("should get abiEncodedRequest with checkSourceAddresses=false and no sourceAddressesRoot", async () => {
it.skip("should get abiEncodedRequest with checkSourceAddresses=false and no sourceAddressesRoot", async () => {
const payload = {
attestationType: "0x5265666572656e6365645061796d656e744e6f6e6578697374656e6365000000",
sourceId: "0x74657374444f4745000000000000000000000000000000000000000000000000",
Expand Down
Loading

0 comments on commit 906a046

Please sign in to comment.