Skip to content

Commit

Permalink
Merge remote-tracking branch 'ArkEcosystem/core/develop' into snapsho…
Browse files Browse the repository at this point in the history
…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
vasild committed Oct 1, 2019
2 parents 8e9119b + 14dfc07 commit c3151ab
Show file tree
Hide file tree
Showing 131 changed files with 2,524 additions and 905 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name: Benchmark
on:
push:
branches:
- "**"
- "*"
- "*/*"
pull_request:
types: [ready_for_review, synchronize, opened] # fix: synchronize triggers builds for PR merges with the base branch, currently causes duplicate builds as synchronize is treated the same as push for everything besides merges

Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/functional.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name: Functional
on:
push:
branches:
- "**"
- "*"
- "*/*"
pull_request:
types: [ready_for_review, synchronize, opened] # fix: synchronize triggers builds for PR merges with the base branch, currently causes duplicate builds as synchronize is treated the same as push for everything besides merges

Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name: Test
on:
push:
branches:
- "**"
- "*"
- "*/*"
pull_request:
types: [ready_for_review, synchronize, opened] # fix: synchronize triggers builds for PR merges with the base branch, currently causes duplicate builds as synchronize is treated the same as push for everything besides merges

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const setUp = async (): Promise<void> => {
"@arkecosystem/core-logger-pino",
"@arkecosystem/core-state",
"@arkecosystem/core-database-postgres",
"@arkecosystem/core-marketplace",
"@arkecosystem/core-magistrate-transactions",
"@arkecosystem/core-transaction-pool",
"@arkecosystem/core-p2p",
"@arkecosystem/core-blockchain",
Expand Down
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();
});
});
});
Loading

0 comments on commit c3151ab

Please sign in to comment.