-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Fix: official repo to list Solidity's releases #5008
Changes from 6 commits
320db95
3b0e4f6
18f85cb
c709ec6
301ae21
248dcb8
0f320f3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -150,13 +150,11 @@ describe("CompilerSupplier", function () { | |
Config.getTruffleDataDirectory(), | ||
"compilers/node_modules" | ||
); | ||
const expectedCache = path.resolve( | ||
compilerCacheDirectory, | ||
"soljson-v0.4.21+commit.dfe3193c.js" | ||
); | ||
|
||
// Delete if it's already there. | ||
if (await fse.exists(expectedCache)) await fse.unlink(expectedCache); | ||
if (fse.existsSync(compilerCacheDirectory)) { | ||
fse.removeSync(compilerCacheDirectory); | ||
} | ||
|
||
options.compilers = { | ||
solc: { version: "0.4.21" } | ||
|
@@ -170,10 +168,24 @@ describe("CompilerSupplier", function () { | |
options: cachedOptions | ||
}); | ||
|
||
assert(await fse.exists(expectedCache), "Should have cached compiler"); | ||
const cachedCompilerFilenames = fse.readdirSync(compilerCacheDirectory); | ||
const compilerFilename = cachedCompilerFilenames.find(filename => { | ||
return filename.includes("v0.4.21+commit.dfe3193c"); | ||
}); | ||
|
||
assert.equal( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (Hey @eggplantzzz looks like you inverted this one) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh I did this algorithmically and didn't think about the value - There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh no that's also wrong, it should be defined :P There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, you're just using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh I thought it was using chai...easily remedied |
||
compilerFilename, | ||
undefined, | ||
"The compiler should have been cached but wasn't" | ||
); | ||
|
||
const cachedCompilerPath = path.join( | ||
compilerCacheDirectory, | ||
compilerFilename | ||
); | ||
|
||
// Get cached solc access time | ||
initialAccessTime = (await fse.stat(expectedCache)).atime.getTime(); | ||
initialAccessTime = (await fse.stat(cachedCompilerPath)).atime.getTime(); | ||
|
||
// Wait a second and recompile, verifying that the cached solc | ||
// got accessed / ran ok. | ||
|
@@ -184,7 +196,7 @@ describe("CompilerSupplier", function () { | |
options: cachedOptions | ||
}); | ||
|
||
finalAccessTime = (await fse.stat(expectedCache)).atime.getTime(); | ||
finalAccessTime = (await fse.stat(cachedCompilerPath)).atime.getTime(); | ||
const NewPragma = findOne("NewPragma", compilations[0].contracts); | ||
|
||
assert(NewPragma.contractName === "NewPragma", "Should have compiled"); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,55 +6,52 @@ const path = require("path"); | |
const assert = require("assert"); | ||
const sandbox = require("../sandbox"); | ||
|
||
let logger, config, project, expectedPath; | ||
let logger, config, project, compilersCacheDirectory; | ||
|
||
describe("truffle obtain", function () { | ||
project = path.join(__dirname, "../../sources/obtain"); | ||
|
||
beforeEach(async function () { | ||
expectedPath = path.join( | ||
compilersCacheDirectory = path.join( | ||
Config.getTruffleDataDirectory(), | ||
"compilers", | ||
"node_modules", | ||
"soljson-v0.7.2+commit.51b20bc0.js" | ||
"node_modules" | ||
); | ||
this.timeout(10000); | ||
config = await sandbox.create(project); | ||
logger = new MemoryLogger(); | ||
config.logger = logger; | ||
|
||
// ensure the compiler is not cached beforehand | ||
if (fse.existsSync(compilersCacheDirectory)) { | ||
fse.removeSync(compilersCacheDirectory); | ||
} | ||
}); | ||
|
||
afterEach(() => { | ||
if (fse.existsSync(compilersCacheDirectory)) { | ||
fse.removeSync(compilersCacheDirectory); | ||
} | ||
}); | ||
|
||
it("fetches the solc version specified", async function () { | ||
this.timeout(70000); | ||
// ensure the compiler does not yet exist | ||
try { | ||
fse.unlinkSync(expectedPath); | ||
} catch (error) { | ||
// unlink throws when file doesn't exist | ||
if (error.code !== "ENOENT") { | ||
throw error; | ||
} | ||
} | ||
await CommandRunner.run("obtain --solc=0.7.2", config); | ||
assert(fse.statSync(expectedPath), "The compiler was not obtained!"); | ||
fse.unlinkSync(expectedPath); | ||
const cachedCompilersFilenames = fse.readdirSync(compilersCacheDirectory); | ||
|
||
assert( | ||
cachedCompilersFilenames.some(filename => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same note here as earlier about |
||
return filename.includes("v0.7.2+commit.51b20bc0"); | ||
}), | ||
"The compiler was not obtained!" | ||
); | ||
}); | ||
|
||
it("respects the `quiet` option", async function () { | ||
this.timeout(80000); | ||
// ensure the compiler does not yet exist | ||
try { | ||
fse.unlinkSync(expectedPath); | ||
} catch (error) { | ||
// unlink throws when file doesn't exist | ||
if (error.code !== "ENOENT") { | ||
throw error; | ||
} | ||
} | ||
await CommandRunner.run("obtain --solc=0.7.2 --quiet", config); | ||
// logger.contents() returns false as long as nothing is written to the | ||
// stream that is used for logging in MemoryLogger | ||
|
||
// in Node12, Ganache prints a warning and it cannot be suppressed | ||
// I guess we have to allow it until we stop supporting Node12 | ||
const ganacheNode12WarningRegex = | ||
|
@@ -68,6 +65,5 @@ describe("truffle obtain", function () { | |
!loggedStuff, | ||
"The command logged to the console when it shouldn't have." | ||
); | ||
fse.unlinkSync(expectedPath); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is truly nitpicking and you don't need to change this, but
filename => { return foo; }
could instead just befilename => foo
.