-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'ArkEcosystem/core/develop' into snapsho…
…ts-nonce * ArkEcosystem/core/develop: fix(deps): update dependency @hapi/boom to v8 (#2988) feat(crypto): allow passing height to `configManager.isNewMilestone` (#3001) ci: update branch patterns to new format refactor: remove asset migration heuristic (#2999) chore(deps): update dependency typesync to ^0.6.0 (#2981) refactor(core): use default heap size regardless of available memory (#2998) chore(deps): update dependency cross-env to v6 (#2985) chore(deps): update dependency rimraf to v3 (#2987) refactor: core-magistrate-crypto export namespaces (#2980) feat: multiSignWif (#2979) fix(core-snapshots): export/import transactions' type_group (#2996) chore(deps): update dependency @types/newrelic to v5 (#2984) fix(deps): update dependency node-forge to ^0.9.0 (#2983) feat(core-api): find htlc unlock transactions (#2976) chore(deps): update dependency del-cli to v3 (#2986) fix(deps): update dependency cli-progress to v3 (#2990) fix(deps): update dependency winston-daily-rotate-file to v4 (#2992) fix(core-api): missing orderBy (#2974) feat(core): allow CLI command configurations (#2972) refactor(core-magistrate): Split core-marketplace into core-magistrate-crypto and core-magistrate-transactions (#2967)
- Loading branch information
Showing
131 changed files
with
2,524 additions
and
905 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
266 changes: 192 additions & 74 deletions
266
__tests__/functional/transaction-forging/bridgechain-registration.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,89 +1,207 @@ | ||
import { Identities } from "@arkecosystem/crypto"; | ||
import { generateMnemonic } from "bip39"; | ||
import { TransactionFactory } from "../../helpers/transaction-factory"; | ||
import { secrets } from "../../utils/config/testnet/delegates.json"; | ||
import * as support from "./__support__"; | ||
|
||
const { passphrase } = support.passphrases; | ||
|
||
beforeAll(support.setUp); | ||
afterAll(support.tearDown); | ||
|
||
describe("Transaction Forging - Bridgechain registration", () => { | ||
it("should broadcast, accept and forge it ", async () => { | ||
// Initial Funds | ||
const initialFunds = TransactionFactory.transfer(Identities.Address.fromPassphrase(passphrase), 100 * 1e8) | ||
.withPassphrase(secrets[0]) | ||
.createOne(); | ||
|
||
await expect(initialFunds).toBeAccepted(); | ||
await support.snoozeForBlock(1); | ||
await expect(initialFunds.id).toBeForged(); | ||
|
||
// Registering a business | ||
const businessRegistration = TransactionFactory.businessRegistration({ | ||
name: "arkecosystem", | ||
website: "ark.io", | ||
}) | ||
.withPassphrase(secrets[0]) | ||
.createOne(); | ||
|
||
await expect(businessRegistration).toBeAccepted(); | ||
await support.snoozeForBlock(1); | ||
await expect(businessRegistration.id).toBeForged(); | ||
|
||
// Registering a bridgechain | ||
const bridgechainRegistration = TransactionFactory.bridgechainRegistration({ | ||
name: "cryptoProject", | ||
seedNodes: ["1.2.3.4", "2001:0db8:85a3:0000:0000:8a2e:0370:7334"], | ||
genesisHash: "127e6fbfe24a750e72930c220a8e138275656b8e5d8f48a98c3c92df2caba935", | ||
bridgechainRepository: "somerepository", | ||
}) | ||
.withPassphrase(secrets[0]) | ||
.createOne(); | ||
|
||
await expect(bridgechainRegistration).toBeAccepted(); | ||
await support.snoozeForBlock(1); | ||
await expect(bridgechainRegistration.id).toBeForged(); | ||
describe("Signed with 1 Passphrase", () => { | ||
it("should broadcast, accept and forge it [Signed with 1 Passphrase]", async () => { | ||
// Registering a business | ||
const businessRegistration = TransactionFactory.businessRegistration({ | ||
name: "arkecosystem", | ||
website: "ark.io", | ||
}) | ||
.withPassphrase(secrets[0]) | ||
.createOne(); | ||
|
||
await expect(businessRegistration).toBeAccepted(); | ||
await support.snoozeForBlock(1); | ||
await expect(businessRegistration.id).toBeForged(); | ||
|
||
// Registering a bridgechain | ||
const bridgechainRegistration = TransactionFactory.bridgechainRegistration({ | ||
name: "cryptoProject", | ||
seedNodes: ["1.2.3.4", "2001:0db8:85a3:0000:0000:8a2e:0370:7334"], | ||
genesisHash: "127e6fbfe24a750e72930c220a8e138275656b8e5d8f48a98c3c92df2caba935", | ||
bridgechainRepository: "somerepository", | ||
}) | ||
.withPassphrase(secrets[0]) | ||
.createOne(); | ||
|
||
await expect(bridgechainRegistration).toBeAccepted(); | ||
await support.snoozeForBlock(1); | ||
await expect(bridgechainRegistration.id).toBeForged(); | ||
}); | ||
|
||
it("should broadcast, accept and forge it again [Signed with 1 Passphrase]", async () => { | ||
// Registering a bridgechain again | ||
const bridgechainRegistration = TransactionFactory.bridgechainRegistration({ | ||
name: "cryptoProject", | ||
seedNodes: ["1.2.3.4", "2001:0db8:85a3:0000:0000:8a2e:0370:7334"], | ||
genesisHash: "127e6fbfe24a750e72930c220a8e138275656b8e5d8f48a98c3c92df2caba935", | ||
bridgechainRepository: "somerepository", | ||
}) | ||
.withPassphrase(secrets[0]) | ||
.createOne(); | ||
|
||
await expect(bridgechainRegistration).toBeAccepted(); | ||
await support.snoozeForBlock(1); | ||
await expect(bridgechainRegistration.id).toBeForged(); | ||
}); | ||
|
||
it("should reject bridgechain registration, because business resigned [Signed with 1 Passphrase]", async () => { | ||
// Business resignation | ||
const businessResignation = TransactionFactory.businessResignation() | ||
.withPassphrase(secrets[0]) | ||
.createOne(); | ||
|
||
await expect(businessResignation).toBeAccepted(); | ||
await support.snoozeForBlock(1); | ||
await expect(businessResignation.id).toBeForged(); | ||
|
||
// Bridgechain resignation | ||
const bridgechainRegistration = TransactionFactory.bridgechainRegistration({ | ||
name: "cryptoProject", | ||
seedNodes: ["1.2.3.4", "2001:0db8:85a3:0000:0000:8a2e:0370:7334"], | ||
genesisHash: "127e6fbfe24a750e72930c220a8e138275656b8e5d8f48a98c3c92df2caba935", | ||
bridgechainRepository: "somerepository", | ||
}) | ||
.withPassphrase(secrets[0]) | ||
.createOne(); | ||
|
||
expect(bridgechainRegistration).toBeRejected(); | ||
await support.snoozeForBlock(1); | ||
await expect(bridgechainRegistration.id).not.toBeForged(); | ||
}); | ||
}); | ||
|
||
it("should broadcast, accept and forge it again", async () => { | ||
// Registering a bridgechain again | ||
const bridgechainRegistration = TransactionFactory.bridgechainRegistration({ | ||
name: "cryptoProject", | ||
seedNodes: ["1.2.3.4", "2001:0db8:85a3:0000:0000:8a2e:0370:7334"], | ||
genesisHash: "127e6fbfe24a750e72930c220a8e138275656b8e5d8f48a98c3c92df2caba935", | ||
bridgechainRepository: "somerepository", | ||
}) | ||
.withPassphrase(secrets[0]) | ||
.createOne(); | ||
|
||
await expect(bridgechainRegistration).toBeAccepted(); | ||
await support.snoozeForBlock(1); | ||
await expect(bridgechainRegistration.id).toBeForged(); | ||
describe("Signed with 2 Passphrases", () => { | ||
it("should broadcast, accept and forge it [Signed with 2 Passphrases] ", async () => { | ||
// Prepare a fresh wallet for the tests | ||
const passphrase = generateMnemonic(); | ||
const secondPassphrase = generateMnemonic(); | ||
|
||
// Initial Funds | ||
const initialFunds = TransactionFactory.transfer(Identities.Address.fromPassphrase(passphrase), 150 * 1e8) | ||
.withPassphrase(secrets[0]) | ||
.createOne(); | ||
|
||
await expect(initialFunds).toBeAccepted(); | ||
await support.snoozeForBlock(1); | ||
await expect(initialFunds.id).toBeForged(); | ||
|
||
// Register a second passphrase | ||
const secondSignature = TransactionFactory.secondSignature(secondPassphrase) | ||
.withPassphrase(passphrase) | ||
.createOne(); | ||
|
||
await expect(secondSignature).toBeAccepted(); | ||
await support.snoozeForBlock(1); | ||
await expect(secondSignature.id).toBeForged(); | ||
|
||
// Registering a business | ||
const businessRegistration = TransactionFactory.businessRegistration({ | ||
name: "arkecosystem", | ||
website: "ark.io", | ||
}) | ||
.withPassphrase(passphrase) | ||
.withSecondPassphrase(secondPassphrase) | ||
.createOne(); | ||
|
||
await expect(businessRegistration).toBeAccepted(); | ||
await support.snoozeForBlock(1); | ||
await expect(businessRegistration.id).toBeForged(); | ||
|
||
// Registering a bridgechain | ||
const bridgechainRegistration = TransactionFactory.bridgechainRegistration({ | ||
name: "cryptoProject", | ||
seedNodes: ["2001:0db8:85a3:0000:0000:8a2e:0370:7334"], | ||
genesisHash: "127e6fbfe24a750e72930c220a8e138275656b8e5d8f48a98c3c92df2caba935", | ||
bridgechainRepository: "somerepository", | ||
}) | ||
.withPassphrase(passphrase) | ||
.withSecondPassphrase(secondPassphrase) | ||
.createOne(); | ||
|
||
await expect(bridgechainRegistration).toBeAccepted(); | ||
await support.snoozeForBlock(1); | ||
await expect(bridgechainRegistration.id).toBeForged(); | ||
}); | ||
}); | ||
|
||
it("should reject bridgechain registration, because business resigned", async () => { | ||
// Business resignation | ||
const businessResignation = TransactionFactory.businessResignation() | ||
.withPassphrase(secrets[0]) | ||
.createOne(); | ||
|
||
await expect(businessResignation).toBeAccepted(); | ||
await support.snoozeForBlock(1); | ||
await expect(businessResignation.id).toBeForged(); | ||
|
||
// Bridgechain resignation | ||
const bridgechainRegistration = TransactionFactory.bridgechainRegistration({ | ||
name: "cryptoProject", | ||
seedNodes: ["1.2.3.4", "2001:0db8:85a3:0000:0000:8a2e:0370:7334"], | ||
genesisHash: "127e6fbfe24a750e72930c220a8e138275656b8e5d8f48a98c3c92df2caba935", | ||
bridgechainRepository: "somerepository", | ||
}) | ||
.withPassphrase(secrets[0]) | ||
.createOne(); | ||
|
||
expect(bridgechainRegistration).toBeRejected(); | ||
await support.snoozeForBlock(1); | ||
await expect(bridgechainRegistration.id).not.toBeForged(); | ||
describe("Signed with multi signature [3 of 3]", () => { | ||
// Register a multi signature wallet with defaults | ||
const passphrase = generateMnemonic(); | ||
const passphrases = [passphrase, secrets[4], secrets[5]]; | ||
const participants = [ | ||
Identities.PublicKey.fromPassphrase(passphrases[0]), | ||
Identities.PublicKey.fromPassphrase(passphrases[1]), | ||
Identities.PublicKey.fromPassphrase(passphrases[2]), | ||
]; | ||
|
||
it("should broadcast, accept and forge it [3-of-3 multisig]", async () => { | ||
// Funds to register a multi signature wallet | ||
const initialFunds = TransactionFactory.transfer(Identities.Address.fromPassphrase(passphrase), 50 * 1e8) | ||
.withPassphrase(secrets[0]) | ||
.createOne(); | ||
|
||
await expect(initialFunds).toBeAccepted(); | ||
await support.snoozeForBlock(1); | ||
await expect(initialFunds.id).toBeForged(); | ||
|
||
// Registering a multi-signature wallet | ||
const multiSignature = TransactionFactory.multiSignature(participants, 3) | ||
.withPassphrase(passphrase) | ||
.withPassphraseList(passphrases) | ||
.createOne(); | ||
|
||
await expect(multiSignature).toBeAccepted(); | ||
await support.snoozeForBlock(1); | ||
await expect(multiSignature.id).toBeForged(); | ||
|
||
// Send funds to multi signature wallet | ||
const multiSigAddress = Identities.Address.fromMultiSignatureAsset(multiSignature.asset.multiSignature); | ||
const multiSigPublicKey = Identities.PublicKey.fromMultiSignatureAsset(multiSignature.asset.multiSignature); | ||
|
||
const multiSignatureFunds = TransactionFactory.transfer(multiSigAddress, 100 * 1e8) | ||
.withPassphrase(secrets[0]) | ||
.createOne(); | ||
|
||
await expect(multiSignatureFunds).toBeAccepted(); | ||
await support.snoozeForBlock(1); | ||
await expect(multiSignatureFunds.id).toBeForged(); | ||
|
||
// Registering a business | ||
const businessRegistration = TransactionFactory.businessRegistration({ | ||
name: "ark", | ||
website: "ark.io", | ||
}) | ||
.withSenderPublicKey(multiSigPublicKey) | ||
.withPassphraseList(passphrases) | ||
.createOne(); | ||
|
||
await expect(businessRegistration).toBeAccepted(); | ||
await support.snoozeForBlock(1); | ||
await expect(businessRegistration.id).toBeForged(); | ||
|
||
// Registering a bridgechain | ||
const bridgechainRegistration = TransactionFactory.bridgechainRegistration({ | ||
name: "cryptoProject", | ||
seedNodes: ["2001:0db8:85a3:0000:0000:8a2e:0370:7334"], | ||
genesisHash: "127e6fbfe24a750e72930c220a8e138275656b8e5d8f48a98c3c92df2caba935", | ||
bridgechainRepository: "somerepository", | ||
}) | ||
.withSenderPublicKey(multiSigPublicKey) | ||
.withPassphraseList(passphrases) | ||
.createOne(); | ||
|
||
await expect(bridgechainRegistration).toBeAccepted(); | ||
await support.snoozeForBlock(1); | ||
await expect(bridgechainRegistration.id).toBeForged(); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.