aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-07-13 22:06:15 +0800
committerFabio Berger <me@fabioberger.com>2018-07-13 22:06:15 +0800
commit25681754bd3bb963e3348636a4659d6d426ed9e4 (patch)
tree6278ee11a07b7c039b3be80afe4a78e2f6b81cad /packages
parent179c487da958dedda0f1a8cd93a2ce67f169e53c (diff)
downloaddexon-sol-tools-25681754bd3bb963e3348636a4659d6d426ed9e4.tar
dexon-sol-tools-25681754bd3bb963e3348636a4659d6d426ed9e4.tar.gz
dexon-sol-tools-25681754bd3bb963e3348636a4659d6d426ed9e4.tar.bz2
dexon-sol-tools-25681754bd3bb963e3348636a4659d6d426ed9e4.tar.lz
dexon-sol-tools-25681754bd3bb963e3348636a4659d6d426ed9e4.tar.xz
dexon-sol-tools-25681754bd3bb963e3348636a4659d6d426ed9e4.tar.zst
dexon-sol-tools-25681754bd3bb963e3348636a4659d6d426ed9e4.zip
Fix abi-gen tests to not rely on sleep, since it causes intermittent failures
Diffstat (limited to 'packages')
-rw-r--r--packages/abi-gen/test/utils_test.ts13
1 files changed, 7 insertions, 6 deletions
diff --git a/packages/abi-gen/test/utils_test.ts b/packages/abi-gen/test/utils_test.ts
index c6147df38..f3dd38035 100644
--- a/packages/abi-gen/test/utils_test.ts
+++ b/packages/abi-gen/test/utils_test.ts
@@ -13,8 +13,6 @@ chai.use(dirtyChai);
const expect = chai.expect;
-const SLEEP_MS = 10; // time to wait before re-timestamping a file
-
describe('makeOutputFileName()', () => {
it('should handle Metacoin usage', () => {
expect(utils.makeOutputFileName('Metacoin')).to.equal('metacoin');
@@ -65,19 +63,22 @@ describe('isOutputFileUpToDate()', () => {
describe('with an existing output file', () => {
let outputFile: string;
before(() => {
- sleep.msleep(SLEEP_MS); // to ensure different timestamp
outputFile = tmp.fileSync(
{ discardDescriptor: true }, // close file (set timestamp)
).name;
+ const abiFileModTimeMs = fs.statSync(abiFile).mtimeMs;
+ const outfileModTimeMs = abiFileModTimeMs + 1;
+ fs.utimesSync(outputFile, outfileModTimeMs, outfileModTimeMs);
});
- it('should return true when output file and is newer than abi file', async () => {
+ it('should return true when output file is newer than abi file', async () => {
expect(utils.isOutputFileUpToDate(abiFile, outputFile)).to.be.true();
});
it('should return false when output file exists but is older than abi file', () => {
- sleep.msleep(SLEEP_MS); // to ensure different timestamp
- fs.closeSync(fs.openSync(abiFile, 'w')); // touch abi file
+ const outFileModTimeMs = fs.statSync(outputFile).mtimeMs;
+ const abiFileModTimeMs = outFileModTimeMs + 1;
+ fs.utimesSync(abiFile, abiFileModTimeMs, abiFileModTimeMs);
expect(utils.isOutputFileUpToDate(abiFile, outputFile)).to.be.false();
});