Skip to content

Commit

Permalink
refactor(core-magistrate-crypto): use URI schema for website an… (#3162)
Browse files Browse the repository at this point in the history
  • Loading branch information
spkjp committed Nov 21, 2019
1 parent 76c7f8d commit 55a8bbb
Show file tree
Hide file tree
Showing 10 changed files with 138 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe("Transaction Forging - Bridgechain registration", () => {
const businessRegistration = TransactionFactory.init(app)
.businessRegistration({
name: "arkecosystem",
website: "ark.io",
website: "https://ark.io",
})
.withPassphrase(secrets[0])
.createOne();
Expand All @@ -34,7 +34,7 @@ describe("Transaction Forging - Bridgechain registration", () => {
name: "cryptoProject",
seedNodes: ["1.2.3.4", "2001:0db8:85a3:0000:0000:8a2e:0370:7334"],
genesisHash: "127e6fbfe24a750e72930c220a8e138275656b8e5d8f48a98c3c92df2caba935",
bridgechainRepository: "somerepository",
bridgechainRepository: "http://www.repository.com/myorg/myrepo",
})
.withPassphrase(secrets[0])
.createOne();
Expand All @@ -50,7 +50,7 @@ describe("Transaction Forging - Bridgechain registration", () => {
name: "cryptoProject2",
seedNodes: ["1.2.3.4", "2001:0db8:85a3:0000:0000:8a2e:0370:7334"],
genesisHash: "127e6fbfe24a750e72930c220a8e138275656b8e5d8f48a98c3c92df2caba935",
bridgechainRepository: "somerepository",
bridgechainRepository: "http://www.repository.com/myorg/myrepo",
})
.withPassphrase(secrets[0])
.createOne();
Expand All @@ -59,7 +59,7 @@ describe("Transaction Forging - Bridgechain registration", () => {
name: "cryptoProject2",
seedNodes: ["1.2.3.4", "2001:0db8:85a3:0000:0000:8a2e:0370:7334"],
genesisHash: "127e6fbfe24a750e72930c220a8e138275656b8e5d8f48a98c3c92df2caba935",
bridgechainRepository: "somerepository",
bridgechainRepository: "http://www.repository.com/myorg/myrepo",
})
.withPassphrase(secrets[0])
.withNonce(bridgechainRegistration.nonce.plus(1))
Expand All @@ -78,7 +78,7 @@ describe("Transaction Forging - Bridgechain registration", () => {
name: "cryptoProject",
seedNodes: ["1.2.3.4", "2001:0db8:85a3:0000:0000:8a2e:0370:7334"],
genesisHash: "127e6fbfe24a750e72930c220a8e138275656b8e5d8f48a98c3c92df2caba935",
bridgechainRepository: "somerepository",
bridgechainRepository: "http://www.repository.com/myorg/myrepo",
})
.withPassphrase(secrets[0])
.createOne();
Expand Down Expand Up @@ -137,7 +137,7 @@ describe("Transaction Forging - Bridgechain registration", () => {
name: "cryptoProject",
seedNodes: ["1.2.3.4", "2001:0db8:85a3:0000:0000:8a2e:0370:7334"],
genesisHash: "127e6fbfe24a750e72930c220a8e138275656b8e5d8f48a98c3c92df2caba935",
bridgechainRepository: "somerepository",
bridgechainRepository: "http://www.repository.com/myorg/myrepo",
})
.withPassphrase(secrets[0])
.createOne();
Expand All @@ -146,6 +146,34 @@ describe("Transaction Forging - Bridgechain registration", () => {
await snoozeForBlock(1);
await expect(bridgechainRegistration.id).not.toBeForged();
});

it("should reject bridgechain registration, because bridgechainRepository is invalid uri [Signed with 1 Passphrase]", async () => {
// Business registration
const businessRegistration = TransactionFactory.businessRegistration({
name: "arkecosystem",
website: "https://ark.io",
})
.withPassphrase(secrets[5])
.createOne();

await expect(businessRegistration).toBeAccepted();
await snoozeForBlock(1);
await expect(businessRegistration.id).toBeForged();

// Bridgechain registration
const bridgechainRegistration = TransactionFactory.bridgechainRegistration({
name: "cryptoProject",
seedNodes: ["1.2.3.4", "2001:0db8:85a3:0000:0000:8a2e:0370:7334"],
genesisHash: "127e6fbfe24a750e72930c220a8e138275656b8e5d8f48a98c3c92df2caba935",
bridgechainRepository: "repository.com/myorg/myrepo",
})
.withPassphrase(secrets[5])
.createOne();

await expect(bridgechainRegistration).toBeRejected();
await snoozeForBlock(1);
await expect(bridgechainRegistration.id).not.toBeForged();
});
});

describe("Signed with 2 Passphrases", () => {
Expand Down Expand Up @@ -194,7 +222,7 @@ describe("Transaction Forging - Bridgechain registration", () => {
name: "cryptoProject",
seedNodes: ["2001:0db8:85a3:0000:0000:8a2e:0370:7334"],
genesisHash: "127e6fbfe24a750e72930c220a8e138275656b8e5d8f48a98c3c92df2caba935",
bridgechainRepository: "somerepository",
bridgechainRepository: "http://www.repository.com/myorg/myrepo",
})
.withPassphrase(passphrase)
.withSecondPassphrase(secondPassphrase)
Expand Down Expand Up @@ -271,7 +299,7 @@ describe("Transaction Forging - Bridgechain registration", () => {
name: "cryptoProject",
seedNodes: ["2001:0db8:85a3:0000:0000:8a2e:0370:7334"],
genesisHash: "127e6fbfe24a750e72930c220a8e138275656b8e5d8f48a98c3c92df2caba935",
bridgechainRepository: "somerepository",
bridgechainRepository: "http://www.repository.com/myorg/myrepo",
})
.withSenderPublicKey(multiSigPublicKey)
.withPassphraseList(passphrases)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe("Transaction Forging - Bridgechain resignation", () => {
const businessRegistration = TransactionFactory.init(app)
.businessRegistration({
name: "ark",
website: "ark.io",
website: "https://ark.io",
})
.withPassphrase(secrets[0])
.createOne();
Expand All @@ -34,7 +34,7 @@ describe("Transaction Forging - Bridgechain resignation", () => {
name: "cryptoProject",
seedNodes: ["1.2.3.4", "2001:0db8:85a3:0000:0000:8a2e:0370:7334"],
genesisHash: "127e6fbfe24a750e72930c220a8e138275656b8e5d8f48a98c3c92df2caba935",
bridgechainRepository: "www.repository.com/myorg/myrepo",
bridgechainRepository: "http://www.repository.com/myorg/myrepo",
})
.withPassphrase(secrets[0])
.createOne();
Expand Down Expand Up @@ -125,7 +125,7 @@ describe("Transaction Forging - Bridgechain resignation", () => {
const businessRegistration = TransactionFactory.init(app)
.businessRegistration({
name: "arkecosystem",
website: "ark.io",
website: "https://ark.io",
})
.withPassphrase(passphrase)
.withSecondPassphrase(secondPassphrase)
Expand All @@ -141,7 +141,7 @@ describe("Transaction Forging - Bridgechain resignation", () => {
name: "cryptoProject",
seedNodes: ["2001:0db8:85a3:0000:0000:8a2e:0370:7334"],
genesisHash: "127e6fbfe24a750e72930c220a8e138275656b8e5d8f48a98c3c92df2caba935",
bridgechainRepository: "somerepository",
bridgechainRepository: "http://www.repository.com/myorg/myrepo",
})
.withPassphrase(passphrase)
.withSecondPassphrase(secondPassphrase)
Expand Down Expand Up @@ -212,7 +212,7 @@ describe("Transaction Forging - Bridgechain resignation", () => {
const businessRegistration = TransactionFactory.init(app)
.businessRegistration({
name: "ark",
website: "ark.io",
website: "https://ark.io",
})
.withSenderPublicKey(multiSigPublicKey)
.withPassphraseList(passphrases)
Expand All @@ -228,7 +228,7 @@ describe("Transaction Forging - Bridgechain resignation", () => {
name: "cryptoProject",
seedNodes: ["2001:0db8:85a3:0000:0000:8a2e:0370:7334"],
genesisHash: "127e6fbfe24a750e72930c220a8e138275656b8e5d8f48a98c3c92df2caba935",
bridgechainRepository: "somerepository",
bridgechainRepository: "http://www.repository.com/myorg/myrepo",
})
.withSenderPublicKey(multiSigPublicKey)
.withPassphraseList(passphrases)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe("Transaction Forging - Bridgechain update", () => {
const businessRegistration = TransactionFactory.init(app)
.businessRegistration({
name: "ark",
website: "ark.io",
website: "https://ark.io",
})
.withPassphrase(secrets[0])
.createOne();
Expand All @@ -34,7 +34,7 @@ describe("Transaction Forging - Bridgechain update", () => {
name: "cryptoProject",
seedNodes: ["1.2.3.4", "2001:0db8:85a3:0000:0000:8a2e:0370:7334"],
genesisHash: "127e6fbfe24a750e72930c220a8e138275656b8e5d8f48a98c3c92df2caba935",
bridgechainRepository: "somerepository",
bridgechainRepository: "http://www.repository.com/myorg/myrepo",
})
.withPassphrase(secrets[0])
.createOne();
Expand Down Expand Up @@ -88,7 +88,7 @@ describe("Transaction Forging - Bridgechain update", () => {
name: "cryptoProject2",
seedNodes: ["1.2.3.4", "2001:0db8:85a3:0000:0000:8a2e:0370:7334"],
genesisHash: "127e6fbfe24a750e72930c220a8e138275656b8e5d8f48a98c3c92df2caba935",
bridgechainRepository: "somerepository",
bridgechainRepository: "http://www.repository.com/myorg/myrepo",
})
.withPassphrase(secrets[0])
.createOne();
Expand Down Expand Up @@ -149,7 +149,7 @@ describe("Transaction Forging - Bridgechain update", () => {
const businessRegistration = TransactionFactory.init(app)
.businessRegistration({
name: "arkecosystem",
website: "ark.io",
website: "https://ark.io",
})
.withPassphrase(passphrase)
.withSecondPassphrase(secondPassphrase)
Expand All @@ -165,7 +165,7 @@ describe("Transaction Forging - Bridgechain update", () => {
name: "cryptoProject",
seedNodes: ["2001:0db8:85a3:0000:0000:8a2e:0370:7334"],
genesisHash: "127e6fbfe24a750e72930c220a8e138275656b8e5d8f48a98c3c92df2caba935",
bridgechainRepository: "somerepository",
bridgechainRepository: "http://www.repository.com/myorg/myrepo",
})
.withPassphrase(passphrase)
.withSecondPassphrase(secondPassphrase)
Expand Down Expand Up @@ -239,7 +239,7 @@ describe("Transaction Forging - Bridgechain update", () => {
const businessRegistration = TransactionFactory.init(app)
.businessRegistration({
name: "ark",
website: "ark.io",
website: "https://ark.io",
})
.withSenderPublicKey(multiSigPublicKey)
.withPassphraseList(passphrases)
Expand All @@ -255,7 +255,7 @@ describe("Transaction Forging - Bridgechain update", () => {
name: "cryptoProject",
seedNodes: ["2001:0db8:85a3:0000:0000:8a2e:0370:7334"],
genesisHash: "127e6fbfe24a750e72930c220a8e138275656b8e5d8f48a98c3c92df2caba935",
bridgechainRepository: "somerepository",
bridgechainRepository: "http://www.repository.com/myorg/myrepo",
})
.withSenderPublicKey(multiSigPublicKey)
.withPassphraseList(passphrases)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe("Transaction Forging - Business registration", () => {
const businessRegistration = TransactionFactory.init(app)
.businessRegistration({
name: "ark",
website: "ark.io",
website: "https://ark.io",
})
.withPassphrase(secrets[0])
.createOne();
Expand All @@ -34,7 +34,7 @@ describe("Transaction Forging - Business registration", () => {
const businessRegistration = TransactionFactory.init(app)
.businessRegistration({
name: "ark",
website: "ark.io",
website: "https://ark.io",
})
.withPassphrase(secrets[0])
.createOne();
Expand All @@ -48,7 +48,7 @@ describe("Transaction Forging - Business registration", () => {
// Registering a business with unicode control characters in its name
const businessRegistration = TransactionFactory.businessRegistration({
name: "\u0000ark",
website: "ark.io",
website: "https://ark.io",
})
.withPassphrase(secrets[1])
.createOne();
Expand All @@ -62,7 +62,7 @@ describe("Transaction Forging - Business registration", () => {
// Registering a business with disallowed characters in its name
const businessRegistration = TransactionFactory.businessRegistration({
name: "ark+",
website: "ark.io",
website: "https://ark.io",
})
.withPassphrase(secrets[1])
.createOne();
Expand All @@ -77,15 +77,15 @@ describe("Transaction Forging - Business registration", () => {
// Registering a business
const businessRegistration = TransactionFactory.businessRegistration({
name: "ark",
website: "ark.io",
website: "https://ark.io",
})
.withPassphrase(secrets[1])
.createOne();

// Registering a business again
const businessRegistration2 = TransactionFactory.businessRegistration({
name: "ark2",
website: "ark.io",
website: "https://ark.io",
})
.withPassphrase(secrets[1])
.withNonce(businessRegistration.nonce.plus(1))
Expand All @@ -96,6 +96,35 @@ describe("Transaction Forging - Business registration", () => {
await expect(businessRegistration.id).toBeForged();
await expect(businessRegistration2.id).not.toBeForged();
});

it("should be rejected, because website is not valid uri [Signed with 1 Passphrase]", async () => {
// Registering a business
const businessRegistration = TransactionFactory.businessRegistration({
name: "ark",
website: "ark.io",
})
.withPassphrase(secrets[2])
.createOne();

await expect(businessRegistration).toBeRejected();
await snoozeForBlock(1);
await expect(businessRegistration.id).not.toBeForged();
});

it("should be rejected, because repository is not valid uri [Signed with 1 Passphrase]", async () => {
// Registering a business
const businessRegistration = TransactionFactory.businessRegistration({
name: "ark",
website: "https://ark.io",
repository: "http//ark.io/repo",
})
.withPassphrase(secrets[3])
.createOne();

await expect(businessRegistration).toBeRejected();
await snoozeForBlock(1);
await expect(businessRegistration.id).not.toBeForged();
});
});

describe("Signed with 2 Passphrases", () => {
Expand Down Expand Up @@ -128,7 +157,7 @@ describe("Transaction Forging - Business registration", () => {
const businessRegistration = TransactionFactory.init(app)
.businessRegistration({
name: "ark",
website: "ark.io",
website: "https://ark.io",
})
.withPassphrase(passphrase)
.withSecondPassphrase(secondPassphrase)
Expand All @@ -144,7 +173,7 @@ describe("Transaction Forging - Business registration", () => {
const businessRegistration = TransactionFactory.init(app)
.businessRegistration({
name: "ark",
website: "ark.io",
website: "https://ark.io",
})
.withPassphrase(passphrase)
.withSecondPassphrase(secondPassphrase)
Expand Down Expand Up @@ -209,7 +238,7 @@ describe("Transaction Forging - Business registration", () => {
const businessRegistration = TransactionFactory.init(app)
.businessRegistration({
name: "ark",
website: "ark.io",
website: "https://ark.io",
})
.withSenderPublicKey(multiSigPublicKey)
.withPassphraseList(signPassphrases)
Expand All @@ -225,7 +254,7 @@ describe("Transaction Forging - Business registration", () => {
const businessRegistration = TransactionFactory.init(app)
.businessRegistration({
name: "ark",
website: "ark.io",
website: "https://ark.io",
})
.withSenderPublicKey(multiSigPublicKey)
.withPassphraseList(signPassphrases)
Expand Down
Loading

0 comments on commit 55a8bbb

Please sign in to comment.