Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit 6885f47

Browse files
Merge pull request #5253 from trufflesuite/further-test-work
Internal improvement: Further simplify scenario tests
2 parents 57e0414 + 26279d3 commit 6885f47

File tree

18 files changed

+128
-210
lines changed

18 files changed

+128
-210
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const sandbox = require("../sandbox");
2+
const CommandRunner = require("../commandRunner");
3+
const fs = require("fs");
4+
const path = require("path");
5+
const { assert } = require("chai");
6+
const Server = require("../server");
7+
8+
describe("truffle compile", function () {
9+
let config;
10+
const project = path.join(__dirname, "../../sources/toyProject");
11+
12+
before(async () => {
13+
await Server.start();
14+
config = await sandbox.create(project);
15+
});
16+
after(async function () {
17+
await Server.stop();
18+
});
19+
20+
it("compiles", async function () {
21+
this.timeout(20000);
22+
await CommandRunner.run("compile", config);
23+
assert(
24+
fs.existsSync(
25+
path.join(config.contracts_build_directory, "Migrations.json")
26+
)
27+
);
28+
});
29+
});

packages/truffle/test/scenarios/commands/console.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,6 @@ describe("truffle console", () => {
6969
config = { working_directory: sandlot.name };
7070
config.logger = logger;
7171
});
72-
after("clear working_directory", () => {
73-
sandlot.removeCallback();
74-
});
7572

7673
it("displays the url hostname in the prompt", async () => {
7774
await CommandRunner.runInREPL({
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
const sandbox = require("../sandbox");
2+
const MemoryLogger = require("../MemoryLogger");
3+
const CommandRunner = require("../commandRunner");
4+
const path = require("path");
5+
const { assert } = require("chai");
6+
const Server = require("../server");
7+
8+
describe("truffle test", function () {
9+
let config;
10+
const logger = new MemoryLogger();
11+
const project = path.join(__dirname, "../../sources/toyProject");
12+
13+
before(async () => {
14+
await Server.start();
15+
config = await sandbox.create(project);
16+
config.logger = logger;
17+
});
18+
after(async function () {
19+
await Server.stop();
20+
});
21+
22+
it("runs tests", async function () {
23+
this.timeout(70000);
24+
await CommandRunner.run("test", config);
25+
const output = logger.contents();
26+
assert(output.includes("1 passing"));
27+
});
28+
});

packages/truffle/test/scenarios/contract_names/test_imports.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,15 @@ describe("Contract names", function () {
1212
const logger = new MemoryLogger();
1313
const project = path.join(__dirname, "../../sources/contract_names");
1414

15-
before(async function () {
16-
await Server.start();
17-
});
18-
after(async function () {
19-
await Server.stop();
20-
});
21-
2215
before(async function () {
2316
this.timeout(10000);
2417
config = await sandbox.create(project);
2518
config.network = "development";
2619
config.logger = logger;
20+
await Server.start();
21+
});
22+
after(async function () {
23+
await Server.stop();
2724
});
2825

2926
it("compiles if file names do not match contract names", async function () {

packages/truffle/test/scenarios/genesis_time/genesis_time_invalid.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,20 @@ describe("Genesis time config for truffle test, failing tests [ @standalone ]",
1818
});
1919

2020
describe("test with a bad time stamp", function () {
21-
before("set up sandbox", function () {
21+
before(async function () {
2222
this.timeout(10000);
2323
let project = path.join(
2424
__dirname,
2525
"../../sources/genesis_time/genesis_time_invalid"
2626
);
27-
return sandbox.create(project).then(conf => {
28-
config = conf;
29-
config.network = "test";
30-
config.logger = logger;
31-
});
32-
});
33-
34-
before("ensure path", async () => {
27+
config = await sandbox.create(project);
28+
config.network = "test";
29+
config.logger = logger;
30+
// create test directory
3531
await fs.ensureDir(config.test_directory);
3632
});
3733

38-
it("will run test and output whines about invalid date", async function () {
34+
it("runs test and output whines about invalid date", async function () {
3935
this.timeout(90000);
4036
await CommandRunner.run("test", config);
4137
const output = logger.contents();

packages/truffle/test/scenarios/genesis_time/genesis_time_undefined.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,20 @@ describe("Genesis time config for truffle test, option undefined [ @standalone ]
1818
});
1919

2020
describe("test with undefined option", function () {
21-
before("set up sandbox", function () {
21+
before(async function () {
2222
this.timeout(10000);
2323
let project = path.join(
2424
__dirname,
2525
"../../sources/genesis_time/genesis_time_undefined"
2626
);
27-
return sandbox.create(project).then(conf => {
28-
config = conf;
29-
config.network = "test";
30-
config.logger = logger;
31-
});
32-
});
33-
34-
before("ensure path", async () => {
27+
config = await sandbox.create(project);
28+
config.network = "test";
29+
config.logger = logger;
30+
// create test dir
3531
await fs.ensureDir(config.test_directory);
3632
});
3733

38-
it("will run test and not whine about invalid date", async function () {
34+
it("runs test and doesn't whine about invalid date", async function () {
3935
this.timeout(90000);
4036
await CommandRunner.run("test", config);
4137
const output = logger.contents();

packages/truffle/test/scenarios/genesis_time/genesis_time_valid.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,20 @@ describe("Genesis time config for truffle test, passing tests [ @standalone ]",
1717
});
1818

1919
describe("test with valid date", function () {
20-
before("set up sandbox", function () {
20+
before(async function () {
2121
this.timeout(10000);
2222
let project = path.join(
2323
__dirname,
2424
"../../sources/genesis_time/genesis_time_valid"
2525
);
26-
return sandbox.create(project).then(conf => {
27-
config = conf;
28-
config.network = "test";
29-
config.logger = logger;
30-
});
31-
});
32-
33-
before("ensure path", async () => {
26+
config = await sandbox.create(project);
27+
config.network = "test";
28+
config.logger = logger;
29+
// create test dir
3430
await fs.ensureDir(config.test_directory);
3531
});
3632

37-
it("will run test and error should be undefined", async function () {
33+
it("runs test and won't error", async function () {
3834
this.timeout(90000);
3935
await CommandRunner.run("test", config);
4036
});

packages/truffle/test/scenarios/happy_path/happypath.js

Lines changed: 0 additions & 88 deletions
This file was deleted.

packages/truffle/test/scenarios/migrations/describe-json.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,16 +126,11 @@ describe("truffle migrate --describe-json", () => {
126126
describe("without existing migration (i.e. clean slate)", () => {
127127
let statuses = [];
128128

129-
before("before all setup", done => {
129+
before(async () => {
130130
projectPath = path.join(__dirname, "../../sources/migrations/init");
131-
sandbox
132-
.create(projectPath)
133-
.then(conf => {
134-
config = conf;
135-
config.network = "development";
136-
config.logger = logger;
137-
})
138-
.then(done);
131+
config = await sandbox.create(projectPath);
132+
config.network = "development";
133+
config.logger = logger;
139134
});
140135

141136
it("runs the migration without throwing", async () => {

packages/truffle/test/scenarios/migrations/init.js

Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)