Skip to content

Commit

Permalink
add - test on shelley certificates.
Browse files Browse the repository at this point in the history
these is a pretty lame test.
We cannot follow the previous test strategy of comparing to known good results because we don't have any
known good results.

Instead, we just check to ensure that the return objects are sensible.
We only focus on the two types of certs that have complicated subfields.

The addresses for the tests I just pulled out of mainnet because they had certs that I wanted to inspect.

The tests mostly ensure that the postgresql json encoding works correctly.
  • Loading branch information
Matthew Eric Bassett committed Aug 3, 2020
1 parent 7778474 commit afec8a2
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/txHistory.test.ts
Expand Up @@ -2,6 +2,7 @@ import axios from "axios";
import { expect } from "chai";
import { resultsForSingleHistory } from "./dataSingleHistory";
import { config, Config } from "./config";
import { Certificate, TransactionFrag } from "../src/Transactions/types";
import * as R from "ramda";

const endpoint = config.apiUrl;
Expand Down Expand Up @@ -93,6 +94,12 @@ const dataTxOrdering = {
, untilBlock: hashForUntilBlock
};

const dataShelleyCerts = {
addresses: ["addr1q9ya8v4pe33nlkgftyd70nhhp407pvnjjcsddhf64sh9gegwtvyxm7r69gx9cwvtg82p87zpwmzj0kj7tjmyraze3pzqe6zxzv"
,"addr1v8vqle5aa50ljr6pu5ndqve29luch29qmpwwhz2pk5tcggqn3q8mu"]
, untilBlock: "bca4bb9095b3d95dfb36ad5a559553e02770bcfe96702315b1175b43b5aeac82"
};

const testableUri = endpoint + "v2/txs/history";


Expand Down Expand Up @@ -209,4 +216,29 @@ describe("/txs/history", function() {
expect(result.data[0].outputs[1].address).to.be.eql("Ae2tdPwUPEYynjShTL8D2L2GGggTH3AGtMteb7r65oLar1vzZ4JPfxob4b8");
expect(result.data[0].outputs[1].amount).to.be.eql("98000000");
});
it("should get sensible shelley certificates", async() => {
const result = await axios.post(testableUri, dataShelleyCerts);
const resultsWithCerts = result.data.filter( (obj: TransactionFrag) => obj.certificates.length > 0);
const certs = resultsWithCerts.map( (obj: TransactionFrag) => obj.certificates).flat();
expect(certs).to.not.be.empty;

const poolRegCert = certs.filter ( (c:Certificate) => c.kind === "PoolRegistration")[0];
poolRegCert.poolParams.poolOwners.every( (item:any) => {
expect(typeof item).to.be.equal("string");
});
poolRegCert.poolParams.relays.every((item:any) => {
expect(item).to.have.property("ipv6");
expect(item).to.have.property("ipv4");
expect(item).to.have.property("dnsName");
expect(item).to.have.property("dnsSrvName");
expect(item).to.have.property("port");
});
expect(poolRegCert.poolParams.poolMetadata).to.have.property("url");
expect(poolRegCert.poolParams.poolMetadata).to.have.property("metadataHash");

const mirCert = certs.filter ( (c:Certificate) => c.kind === "MoveInstantaneousRewardsCert")[0];
mirCert.rewards.every( (item:any) => {
expect(typeof item).to.be.equal("string");
});
});
});

0 comments on commit afec8a2

Please sign in to comment.