Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core-magistrate-crypto): add ports to bridgechain registration/update #3255

Merged
merged 27 commits into from
Nov 20, 2019
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
c794f5b
feat: add ports to bridgechain registration serde
dated Nov 13, 2019
d22db35
feat: add ports to bridgechain update serde
dated Nov 13, 2019
15a9409
fix: const/let
dated Nov 13, 2019
9937fa7
test: adjust unit tests
dated Nov 13, 2019
345bc79
test: adjust functional tests
dated Nov 13, 2019
5993880
fix: typo
dated Nov 13, 2019
a0efb72
test: adjust functional tests
dated Nov 13, 2019
4cbcb56
refactor: allow only @arkecosystem/core-api for now
dated Nov 13, 2019
9fde1f4
Merge branch 'develop' into feat/bridgechain-ports
faustbrian Nov 13, 2019
c7c237f
refactor: cleanup buffer sizes
dated Nov 14, 2019
4ffa01c
fix: bridgechain update deserializer
dated Nov 14, 2019
46926af
refactor: cleanup buffer sizes
dated Nov 14, 2019
6fc491f
fix: instantiate bridgechainUpdate with bridgechainId
dated Nov 14, 2019
7d470f9
test: add unit tests for bridgechain update schema
dated Nov 14, 2019
92c1bd2
fix: add missing const keywords
dated Nov 14, 2019
d897dd2
fix: port schema validation
dated Nov 14, 2019
e2c5af7
Merge branch 'develop' into feat/bridgechain-ports
dated Nov 16, 2019
d40947d
Merge branch 'develop' into feat/bridgechain-ports
dated Nov 19, 2019
a6e786b
test: adjust tests
dated Nov 19, 2019
cfe63d7
Merge branch 'develop' into feat/bridgechain-ports
dated Nov 19, 2019
f445041
Merge branch 'develop' into feat/bridgechain-ports
faustbrian Nov 19, 2019
e992b5c
test: adjust e2e tests
dated Nov 19, 2019
55f6a07
test: use correct matcher
dated Nov 19, 2019
fcd55cb
refactor: update ports in bridgechain update handlers
dated Nov 19, 2019
86b23d1
refactor: remove fromHex calls
dated Nov 19, 2019
8be73e2
fix: set seedNodes and ports only if included in bridgechain update
dated Nov 19, 2019
daaf899
Merge branch 'develop' into feat/bridgechain-ports
faustbrian Nov 20, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ describe("Check that the bridgechain was registered", () => {
expect(bridgechains[0].seedNodes).toEqual(utils.bridgechainRegistrationAsset.seedNodes);
expect(bridgechains[0].bridgechainRepository).toBe(utils.bridgechainRegistrationAsset.bridgechainRepository);
expect(bridgechains[0].genesisHash).toBe(utils.bridgechainRegistrationAsset.genesisHash);
expect(bridgechains[0].ports).toEqual(utils.bridgechainRegistrationAsset.ports);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ describe("Check that the bridgechain was updated", () => {
expect(bridgechains[0].seedNodes).toEqual(utils.bridgechainUpdateAsset.seedNodes);
expect(bridgechains[0].bridgechainRepository).toBe(utils.bridgechainRegistrationAsset.bridgechainRepository);
expect(bridgechains[0].genesisHash).toBe(utils.bridgechainRegistrationAsset.genesisHash);
expect(bridgechains[0].ports).toEqual(utils.bridgechainUpdateAsset.ports);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ const bridgechainRegistrationAsset = {
],
genesisHash: "127e6fbfe24a750e72930c220a8e138275656b8e5d8f48a98c3c92df2caba935",
bridgechainRepository: "http://www.repository.com/myorg/myrepo",
ports: { "@arkecosystem/core-api": 12345 },
};

const bridgechainUpdateAsset = {
bridgechainId: bridgechainRegistrationAsset.genesisHash,
seedNodes: [
"75.125.224.71",
],
ports: { "@arkecosystem/core-api": 54321 },
};

const bridgechainResignationAsset = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ describe("Transaction Forging - Bridgechain registration", () => {
seedNodes: ["1.2.3.4", "2001:0db8:85a3:0000:0000:8a2e:0370:7334"],
genesisHash: "127e6fbfe24a750e72930c220a8e138275656b8e5d8f48a98c3c92df2caba935",
bridgechainRepository: "http://www.repository.com/myorg/myrepo",
ports: { "@arkecosystem/core-api": 12345 },
})
.withPassphrase(secrets[0])
.createOne();
Expand All @@ -44,6 +45,7 @@ describe("Transaction Forging - Bridgechain registration", () => {
seedNodes: ["1.2.3.4", "2001:0db8:85a3:0000:0000:8a2e:0370:7334"],
genesisHash: "6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b",
bridgechainRepository: "http://www.repository.com/myorg/myrepo",
ports: { "@arkecosystem/core-api": 12345 },
})
.withPassphrase(secrets[0])
.createOne();
Expand All @@ -53,6 +55,7 @@ describe("Transaction Forging - Bridgechain registration", () => {
seedNodes: ["1.2.3.4", "2001:0db8:85a3:0000:0000:8a2e:0370:7334"],
genesisHash: "d4735e3a265e16eee03f59718b9b5d03019c07d8b6c51f90da3a666eec13ab35",
bridgechainRepository: "http://www.repository.com/myorg/myrepo",
ports: { "@arkecosystem/core-api": 12345 },
})
.withPassphrase(secrets[0])
.withNonce(bridgechainRegistration.nonce.plus(1))
Expand All @@ -71,6 +74,7 @@ describe("Transaction Forging - Bridgechain registration", () => {
seedNodes: ["1.2.3.4", "2001:0db8:85a3:0000:0000:8a2e:0370:7334"],
genesisHash: "4e07408562bedb8b60ce05c1decfe3ad16b72230967de01f640b7e4729b49fce",
bridgechainRepository: "http://www.repository.com/myorg/myrepo",
ports: { "@arkecosystem/core-api": 12345 },
})
.withPassphrase(secrets[0])
.createOne();
Expand All @@ -87,6 +91,7 @@ describe("Transaction Forging - Bridgechain registration", () => {
seedNodes: ["1.2.3.4", "2001:0db8:85a3:0000:0000:8a2e:0370:7334"],
genesisHash: "4b227777d4dd1fc61c6f884f48641d02b4d121d3fd328cb08b5531fcacdabf8a",
bridgechainRepository: "http://www.repository.com/myorg/myrepo",
ports: { "@arkecosystem/core-api": 12345 },
})
.withPassphrase(secrets[0])
.createOne();
Expand Down Expand Up @@ -115,6 +120,7 @@ describe("Transaction Forging - Bridgechain registration", () => {
seedNodes: ["1.2.3.4", "2001:0db8:85a3:0000:0000:8a2e:0370:7334"],
genesisHash: "83cf8b609de60036a8277bd0e96135751bbc07eb234256d4b65b893360651bf2",
bridgechainRepository: "http://www.repository.com/myorg/myrepo",
ports: { "@arkecosystem/core-api": 12345 },
})
.withPassphrase(secrets[1])
.createOne();
Expand All @@ -141,6 +147,7 @@ describe("Transaction Forging - Bridgechain registration", () => {
seedNodes: ["1.2.3.4", "2001:0db8:85a3:0000:0000:8a2e:0370:7334"],
genesisHash: "83cf8b609de60036a8277bd0e96135751bbc07eb234256d4b65b893360651bf2",
bridgechainRepository: "http://www.repository.com/myorg/myrepo",
ports: { "@arkecosystem/core-api": 12345 },
})
.withPassphrase(secrets[2])
.withNonce(bridgechainRegistration.nonce.plus(1))
Expand All @@ -164,6 +171,7 @@ describe("Transaction Forging - Bridgechain registration", () => {
seedNodes: ["1.2.3.4", "2001:0db8:85a3:0000:0000:8a2e:0370:7334"],
genesisHash: `ef2d127de37b942baad06145e54b0c619a1f22327b2ebbcfbec78f5564afe39${i}`,
bridgechainRepository: "http://www.repository.com/myorg/myrepo",
ports: { "@arkecosystem/core-api": 12345 },
})
.withPassphrase(secrets[0])
.createOne(),
Expand Down Expand Up @@ -194,6 +202,7 @@ describe("Transaction Forging - Bridgechain registration", () => {
seedNodes: ["1.2.3.4", "2001:0db8:85a3:0000:0000:8a2e:0370:7334"],
genesisHash: "e7f6c011776e8db7cd330b54174fd76f7d0216b612387a5ffcfb81e6f0919683",
bridgechainRepository: "http://www.repository.com/myorg/myrepo",
ports: { "@arkecosystem/core-api": 12345 },
})
.withPassphrase(secrets[0])
.createOne();
Expand Down Expand Up @@ -222,6 +231,7 @@ describe("Transaction Forging - Bridgechain registration", () => {
seedNodes: ["1.2.3.4", "2001:0db8:85a3:0000:0000:8a2e:0370:7334"],
genesisHash: "7902699be42c8a8e46fbbb4501726517e86b22c56a189f7625a6da49081b2451",
bridgechainRepository: "repository.com/myorg/myrepo",
ports: { "@arkecosystem/core-api": 12345 },
})
.withPassphrase(secrets[5])
.createOne();
Expand Down Expand Up @@ -275,6 +285,7 @@ describe("Transaction Forging - Bridgechain registration", () => {
seedNodes: ["2001:0db8:85a3:0000:0000:8a2e:0370:7334"],
genesisHash: "2c624232cdd221771294dfbb310aca000a0df6ac8b66b696d90ef06fdefb64a3",
bridgechainRepository: "http://www.repository.com/myorg/myrepo",
ports: { "@arkecosystem/core-api": 12345 },
})
.withPassphrase(passphrase)
.withSecondPassphrase(secondPassphrase)
Expand Down Expand Up @@ -347,6 +358,7 @@ describe("Transaction Forging - Bridgechain registration", () => {
seedNodes: ["2001:0db8:85a3:0000:0000:8a2e:0370:7334"],
genesisHash: "19581e27de7ced00ff1ce50b2047e7a567c76b1cbaebabe5ef03f7c3017bb5b7",
bridgechainRepository: "http://www.repository.com/myorg/myrepo",
ports: { "@arkecosystem/core-api": 12345 },
})
.withSenderPublicKey(multiSigPublicKey)
.withPassphraseList(passphrases)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ describe("Transaction Forging - Bridgechain resignation", () => {
seedNodes: ["1.2.3.4", "2001:0db8:85a3:0000:0000:8a2e:0370:7334"],
genesisHash: "4fc82b26aecb47d2868c4efbe3581732a3e7cbcc6c2efb32062c08170a05eeb8",
bridgechainRepository: "http://www.repository.com/myorg/myrepo",
ports: { "@arkecosystem/core-api": 12345 },
};

it("should broadcast, accept and forge it [Signed with 1 Passphrase]", async () => {
// Business registration
const businessRegistration = TransactionFactory.businessRegistration({
Expand Down Expand Up @@ -68,7 +70,9 @@ describe("Transaction Forging - Bridgechain resignation", () => {
seedNodes: ["1.2.3.4", "2001:0db8:85a3:0000:0000:8a2e:0370:7334"],
genesisHash: "6b51d431df5d7f141cbececcf79edf3dd861c3b4069f0b11661a3eefacbba918",
bridgechainRepository: "http://www.repository.com/myorg/myrepo",
ports: { "@arkecosystem/core-api": 12345 },
};

const bridgechainRegistration = TransactionFactory.bridgechainRegistration(bridgechainRegistrationAsset2)
.withPassphrase(secrets[0])
.createOne();
Expand Down Expand Up @@ -140,7 +144,9 @@ describe("Transaction Forging - Bridgechain resignation", () => {
seedNodes: ["2001:0db8:85a3:0000:0000:8a2e:0370:7334"],
genesisHash: "3fdba35f04dc8c462986c992bcf875546257113072a909c162f7e470e581e278",
bridgechainRepository: "http://www.repository.com/myorg/myrepo",
ports: { "@arkecosystem/core-api": 12345 },
};

const bridgechainRegistration = TransactionFactory.bridgechainRegistration(bridgechainRegistrationAsset)
.withPassphrase(passphrase)
.withSecondPassphrase(secondPassphrase)
Expand Down Expand Up @@ -225,7 +231,9 @@ describe("Transaction Forging - Bridgechain resignation", () => {
seedNodes: ["2001:0db8:85a3:0000:0000:8a2e:0370:7334"],
genesisHash: "8527a891e224136950ff32ca212b45bc93f69fbb801c3b1ebedac52775f99e61",
bridgechainRepository: "http://www.repository.com/myorg/myrepo",
ports: { "@arkecosystem/core-api": 12345 },
};

const bridgechainRegistration = TransactionFactory.bridgechainRegistration(bridgechainRegistrationAsset)
.withSenderPublicKey(multiSigPublicKey)
.withPassphraseList(passphrases)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ describe("Transaction Forging - Bridgechain update", () => {
seedNodes: ["1.2.3.4", "2001:0db8:85a3:0000:0000:8a2e:0370:7334"],
genesisHash: "e629fa6598d732768f7c726b4b621285f9c3b85303900aa912017db7617d8bdb",
bridgechainRepository: "http://www.repository.com/myorg/myrepo",
ports: { "@arkecosystem/core-api": 12345 },
};

it("should broadcast, accept and forge it [Signed with 1 Passphrase]", async () => {
Expand Down Expand Up @@ -42,6 +43,7 @@ describe("Transaction Forging - Bridgechain update", () => {
const bridgechainUpdate = TransactionFactory.bridgechainUpdate({
bridgechainId: bridgechainRegistrationAsset.genesisHash,
seedNodes: ["1.2.3.4", "1.2.3.5", "192.168.1.0", "131.107.0.89"],
ports: { "@arkecosystem/core-api": 54321 },
})
.withPassphrase(secrets[0])
.createOne();
Expand Down Expand Up @@ -83,7 +85,9 @@ describe("Transaction Forging - Bridgechain update", () => {
seedNodes: ["1.2.3.4", "2001:0db8:85a3:0000:0000:8a2e:0370:7334"],
genesisHash: "b17ef6d19c7a5b1ee83b907c595526dcb1eb06db8227d650d5dda0a9f4ce8cd9",
bridgechainRepository: "http://www.repository.com/myorg/myrepo",
ports: { "@arkecosystem/core-api": 12345 },
};

const bridgechainRegistration = TransactionFactory.bridgechainRegistration(bridgechainRegistrationAsset2)
.withPassphrase(secrets[0])
.createOne();
Expand Down Expand Up @@ -157,7 +161,9 @@ describe("Transaction Forging - Bridgechain update", () => {
seedNodes: ["2001:0db8:85a3:0000:0000:8a2e:0370:7334"],
genesisHash: "4523540f1504cd17100c4835e85b7eefd49911580f8efff0599a8f283be6b9e3",
bridgechainRepository: "http://www.repository.com/myorg/myrepo",
ports: { "@arkecosystem/core-api": 12345 },
};

const bridgechainRegistration = TransactionFactory.bridgechainRegistration(bridgechainRegistrationAsset)
.withPassphrase(passphrase)
.withSecondPassphrase(secondPassphrase)
Expand Down Expand Up @@ -242,7 +248,9 @@ describe("Transaction Forging - Bridgechain update", () => {
seedNodes: ["2001:0db8:85a3:0000:0000:8a2e:0370:7334"],
genesisHash: "4ec9599fc203d176a301536c2e091a19bc852759b255bd6818810a42c5fed14a",
bridgechainRepository: "http://www.repository.com/myorg/myrepo",
ports: { "@arkecosystem/core-api": 12345 },
};

const bridgechainRegistration = TransactionFactory.bridgechainRegistration(bridgechainRegistrationAsset)
.withSenderPublicKey(multiSigPublicKey)
.withPassphraseList(passphrases)
Expand All @@ -256,6 +264,7 @@ describe("Transaction Forging - Bridgechain update", () => {
const bridgechainUpdate = TransactionFactory.bridgechainUpdate({
bridgechainId: bridgechainRegistrationAsset.genesisHash,
seedNodes: ["1.2.3.4", "1.2.3.5", "192.168.1.0", "131.107.0.89"],
ports: { "@arkecosystem/core-api": 54321 },
})
.withSenderPublicKey(multiSigPublicKey)
.withPassphraseList(passphrases)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ describe("Bridgechain update builder", () => {
.bridgechainUpdateAsset({
bridgechainId: genesisHash,
seedNodes: ["192.168.1.0", "131.107.0.89"],
ports: { "@arkecosystem/core-api": 12345 },
})
.sign("passphrase");
expect(actual.build().verified).toBeTrue();
Expand Down
11 changes: 11 additions & 0 deletions __tests__/unit/core-magistrate/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import "jest-extended";
import { Interfaces } from "@arkecosystem/crypto";
import {
IBridgechainRegistrationAsset,
IBridgechainUpdateAsset,
IBusinessRegistrationAsset,
IBusinessUpdateAsset,
} from "../../../packages/core-magistrate-crypto/src/interfaces";
Expand Down Expand Up @@ -65,13 +66,15 @@ export const bridgechainRegistrationAsset1: IBridgechainRegistrationAsset = {
seedNodes: ["74.125.224.71", "74.125.224.72", "64.233.173.193", "2001:4860:4860::8888", "2001:4860:4860::8844"],
genesisHash: "127e6fbfe24a750e72930c220a8e138275656b8e5d8f48a98c3c92df2caba935",
bridgechainRepository: "http://www.repository.com/myorg/myrepo",
ports: { "@arkecosystem/core-api": 12345 },
};

export const bridgechainRegistrationAsset2: IBridgechainRegistrationAsset = {
name: "arkecosystem2",
seedNodes: ["131.107.0.89"],
genesisHash: "6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b",
bridgechainRepository: "http://www.repository.com/myorg/myrepo",
ports: { "@arkecosystem/core-api": 12345 },
};

export const bridgechainRegistrationAssetBad: IBridgechainRegistrationAsset = {
Expand All @@ -87,4 +90,12 @@ export const bridgechainRegistrationAssetBad: IBridgechainRegistrationAsset = {
],
genesisHash: "127e6fbfe24a750e72930c220a8e138275656b8e5d8f48a98c3c92df2caba935",
bridgechainRepository: "arkecosystem1.com/repo",
ports: { "@arkecosystem/core-api": 12345 },
};

// Birdgechain update assets
export const bridgechainUpdateAsset1: IBridgechainUpdateAsset = {
bridgechainId: "127e6fbfe24a750e72930c220a8e138275656b8e5d8f48a98c3c92df2caba935",
seedNodes: ["1.1.1.1", "2.2.2.2"],
ports: { "@arkecosystem/core-api": 12345 },
};
Loading