This repository has been archived by the owner on Feb 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add integration test to verify behavior from bundle
- Loading branch information
Showing
5 changed files
with
96 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
const MemoryLogger = require("../memorylogger"); | ||
const CommandRunner = require("../commandrunner"); | ||
const path = require("path"); | ||
const assert = require("assert"); | ||
const Server = require("../server"); | ||
const Reporter = require("../reporter"); | ||
const sandbox = require("../sandbox"); | ||
|
||
describe("develop", function () { | ||
let config; | ||
const project = path.join( | ||
__dirname, | ||
"../../sources/develop", | ||
); | ||
const logger = new MemoryLogger(); | ||
|
||
// before(done => Server.start(done)); | ||
// after(done => Server.stop(done)); | ||
|
||
before(async function () { | ||
this.timeout(10000); | ||
config = await sandbox.create(project); | ||
config.network = "development"; | ||
config.logger = logger; | ||
config.mocha = { | ||
reporter: new Reporter(logger), | ||
}; | ||
}); | ||
|
||
it("should load snippets", async function () { | ||
this.timeout(70000); | ||
|
||
await CommandRunner.run("develop", config); | ||
const output = logger.contents(); | ||
|
||
//prepare a helpful message to standout in CI log noise | ||
const formatLines = (lines) => | ||
lines.split("\n").map((line) => `\t---truffle develop log---\t${line}`) | ||
.join("\n"); | ||
const successMessage = "Snippet Loaded"; | ||
assert( | ||
output.includes(successMessage), | ||
`Expected "${successMessage}" in output:\n${formatLines(output)}`, | ||
); | ||
}); | ||
}); |
23 changes: 23 additions & 0 deletions
23
packages/truffle/test/sources/develop/contracts/Migrations.sol
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
pragma solidity ^0.5.0; | ||
|
||
contract Migrations { | ||
address public owner; | ||
uint public last_completed_migration; | ||
|
||
constructor() public { | ||
owner = msg.sender; | ||
} | ||
|
||
modifier restricted() { | ||
if (msg.sender == owner) _; | ||
} | ||
|
||
function setCompleted(uint completed) public restricted { | ||
last_completed_migration = completed; | ||
} | ||
|
||
function upgrade(address new_address) public restricted { | ||
Migrations upgraded = Migrations(new_address); | ||
upgraded.setCompleted(last_completed_migration); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pragma solidity ^0.5.0; | ||
|
||
contract Contract { } |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const main = () => { | ||
console.log("Snippet Loaded"); | ||
|
||
// todo: might need to allow some time for io flush | ||
setTimeout(() => process.exit(0), 0); | ||
} | ||
|
||
main(); |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module.exports = { | ||
networks: { | ||
local: { | ||
host: "127.0.0.1", | ||
port: 8545, | ||
network_id: "*", | ||
gas: 4700000, | ||
gasPrice: 20000000000 | ||
} | ||
}, | ||
console: { | ||
require: [ | ||
{ path: "./snippets/helper.js" } | ||
] | ||
} | ||
}; |