Skip to content

Commit

Permalink
fix: adjust transaction factory for custom network configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Faust committed Feb 28, 2020
1 parent 20bf9ac commit ab27881
Show file tree
Hide file tree
Showing 33 changed files with 50 additions and 9,246 deletions.
6 changes: 3 additions & 3 deletions __tests__/functional/transaction-forging/__support__/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import "jest-extended";

import { Contracts, Container } from "@arkecosystem/core-kernel";
import { Utils, Identities } from "@arkecosystem/crypto";
import { Container, Contracts } from "@arkecosystem/core-kernel";
import { Identities, Utils } from "@arkecosystem/crypto";
import secrets from "@packages/core-test-framework/src/internal/passphrases.json";

jest.setTimeout(1200000);

import { Sandbox } from "@packages/core-test-framework/src";
import { DatabaseService } from "@arkecosystem/core-database";
import { Sandbox } from "@packages/core-test-framework/src";

const sandbox: Sandbox = new Sandbox();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
import "@packages/core-test-framework/src/matchers";

import { Contracts } from "@arkecosystem/core-kernel";
import { Identities, Managers } from "@arkecosystem/crypto";

import { Container, Contracts, Services } from "@arkecosystem/core-kernel";
import { Identities, Interfaces, Managers } from "@arkecosystem/crypto";
import secrets from "@packages/core-test-framework/src/internal/passphrases.json";
import {
snoozeForBlock,
getLastHeight,
injectMilestone,
snoozeForBlock,
TransactionFactory,
} from "@packages/core-test-framework/src/utils";
import secrets from "@packages/core-test-framework/src/internal/passphrases.json";

import * as support from "./__support__";

const { passphrase, secondPassphrase } = support.passphrases;

let app: Contracts.Kernel.Application;
beforeAll(async () => (app = await support.setUp()));
let networkConfig: Interfaces.NetworkConfig;

beforeAll(async () => {
app = await support.setUp();

// todo: remove the need for this and manual calls to withNetworkConfig on the transaction factory
networkConfig = app.get<Services.Config.ConfigRepository>(Container.Identifiers.ConfigRepository).get("crypto");
});

afterAll(async () => await support.tearDown());

describe("Transaction Forging - Multi Signature Registration", () => {
Expand Down Expand Up @@ -93,6 +101,7 @@ describe("Transaction Forging - Multi Signature Registration", () => {
it("should reject before AIP11 milestone and accept after AIP11 milestone", async () => {
const passphrase = secrets[6];
const initialFunds = TransactionFactory.initialize(app)
.withNetworkConfig(networkConfig)
.transfer(Identities.Address.fromPassphrase(passphrase), 100 * 1e8)
.withPassphrase(secrets[0])
.createOne();
Expand All @@ -110,6 +119,7 @@ describe("Transaction Forging - Multi Signature Registration", () => {
];

const multiSignature = TransactionFactory.initialize(app)
.withNetworkConfig(networkConfig)
.multiSignature(participants, 3)
.withPassphraseList(passphrases)
.withPassphrase(passphrase)
Expand Down
23 changes: 17 additions & 6 deletions __tests__/functional/transaction-forging/transfer.test.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
import "@packages/core-test-framework/src/matchers";

import { Contracts } from "@arkecosystem/core-kernel";
import { Identities, Managers } from "@arkecosystem/crypto";

import { Container, Contracts, Services } from "@arkecosystem/core-kernel";
import { Identities, Interfaces, Managers } from "@arkecosystem/crypto";
import secrets from "@packages/core-test-framework/src/internal/passphrases.json";
import {
snoozeForBlock,
getLastHeight,
injectMilestone,
snoozeForBlock,
TransactionFactory,
} from "@packages/core-test-framework/src/utils";
import secrets from "@packages/core-test-framework/src/internal/passphrases.json";

import * as support from "./__support__";

const { passphrase, secondPassphrase } = support.passphrases;

let app: Contracts.Kernel.Application;
beforeAll(async () => (app = await support.setUp()));
let networkConfig: Interfaces.NetworkConfig;

beforeAll(async () => {
app = await support.setUp();

// todo: remove the need for this and manual calls to withNetworkConfig on the transaction factory
networkConfig = app.get<Services.Config.ConfigRepository>(Container.Identifiers.ConfigRepository).get("crypto");
});

afterAll(async () => await support.tearDown());

describe("Transaction Forging - Transfer", () => {
Expand Down Expand Up @@ -153,6 +161,7 @@ describe("Transaction Forging - Transfer", () => {

it("should accept V1 before AIP11 milestone and reject after AIP11 milestone", async () => {
const transfer = TransactionFactory.initialize(app)
.withNetworkConfig(networkConfig)
.transfer(Identities.Address.fromPassphrase(passphrase))
.withPassphrase(secrets[0])
.createOne();
Expand All @@ -162,6 +171,7 @@ describe("Transaction Forging - Transfer", () => {
await expect(transfer.id).toBeForged();

const transfersLegacyWithoutNonce = TransactionFactory.initialize(app)
.withNetworkConfig(networkConfig)
.transfer(Identities.Address.fromPassphrase(passphrase))
.withVersion(1)
.withPassphrase(secrets[0])
Expand Down Expand Up @@ -189,6 +199,7 @@ describe("Transaction Forging - Transfer", () => {

// and accepts V2
const transferWithNonce = TransactionFactory.initialize(app)
.withNetworkConfig(networkConfig)
.transfer(Identities.Address.fromPassphrase(passphrase))
.withPassphrase(secrets[1])
.createOne();
Expand Down
23 changes: 0 additions & 23 deletions __tests__/helpers/block-factory.js

This file was deleted.

8 changes: 0 additions & 8 deletions __tests__/helpers/index.js

This file was deleted.

25 changes: 0 additions & 25 deletions __tests__/helpers/peers.js

This file was deleted.

66 changes: 0 additions & 66 deletions __tests__/helpers/rest-client.js

This file was deleted.

Loading

0 comments on commit ab27881

Please sign in to comment.