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

Commit

Permalink
Merge pull request #1466 from trufflesuite/no-fixed-sourceid
Browse files Browse the repository at this point in the history
Fix intermittent failures of variable ID tests by removing fixed source IDs
  • Loading branch information
haltman-at authored Nov 27, 2018
2 parents c8c7dc9 + 06c7ea6 commit 49a9e7e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
14 changes: 9 additions & 5 deletions packages/truffle-debugger/test/data/ids.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,9 @@ describe("Variable IDs", function() {
let session = bugger.connect();
debug("sourceId %d", session.view(solidity.current.source).id);

session.addBreakpoint({ sourceId: 1, line: 12 });
session.addBreakpoint({ sourceId: 1, line: 22 });
let sourceId = session.view(solidity.current.source).id;
session.addBreakpoint({ sourceId, line: 12 });
session.addBreakpoint({ sourceId, line: 22 });

var values = [];

Expand All @@ -226,7 +227,8 @@ describe("Variable IDs", function() {
let session = bugger.connect();
debug("sourceId %d", session.view(solidity.current.source).id);

session.addBreakpoint({ sourceId: 0, line: 32 });
let sourceId = session.view(solidity.current.source).id;
session.addBreakpoint({ sourceId, line: 32 });
session.continueUntilBreakpoint();
debug("node %o", session.view(solidity.current.node));
assert.equal(session.view(data.current.identifiers.native)["secret"], 107);
Expand All @@ -248,7 +250,8 @@ describe("Variable IDs", function() {
let session = bugger.connect();
debug("sourceId %d", session.view(solidity.current.source).id);

session.addBreakpoint({ sourceId: 2, line: 18 });
let sourceId = session.view(solidity.current.source).id;
session.addBreakpoint({ sourceId, line: 18 });
session.continueUntilBreakpoint();
assert.property(session.view(data.current.identifiers.native), "flag");
});
Expand All @@ -267,7 +270,8 @@ describe("Variable IDs", function() {
let session = bugger.connect();
debug("sourceId %d", session.view(solidity.current.source).id);

session.addBreakpoint({ sourceId: 2, line: 27 });
let sourceId = session.view(solidity.current.source).id;
session.addBreakpoint({ sourceId, line: 27 });
session.continueUntilBreakpoint();
assert.property(session.view(data.current.identifiers.native), "flag");
});
Expand Down
11 changes: 4 additions & 7 deletions packages/truffle-debugger/test/reset.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import debugModule from "debug";
const debug = debugModule("test:reset");
const debug = debugModule("test:reset"); //eslint-disable-line no-unused-vars

import { assert } from "chai";

import Ganache from "ganache-cli";
import Web3 from "web3";

import { prepareContracts } from "./helpers";
import Debugger from "lib/debugger";

import sessionSelector from "lib/session/selectors";
import data from "lib/data/selectors";
import solidity from "lib/solidity/selectors";

const __SETSTHINGS = `
pragma solidity ^0.4.24;
Expand All @@ -35,14 +34,12 @@ let sources = {

describe("Reset Button", function() {
var provider;
var web3;

var abstractions;
var artifacts;

before("Create Provider", async function() {
provider = Ganache.provider({ seed: "debugger", gasLimit: 7000000 });
web3 = new Web3(provider);
});

before("Prepare contracts and artifacts", async function() {
Expand All @@ -64,13 +61,14 @@ describe("Reset Button", function() {
});

let session = bugger.connect();
let sourceId = session.view(solidity.current.source).id;

let variables = [];
variables[0] = []; //collected during 1st run
variables[1] = []; //collected during 2nd run

variables[0].push(session.view(data.current.identifiers.native));
session.addBreakpoint({ sourceId: 0, line: 10 });
session.addBreakpoint({ sourceId, line: 10 });
session.continueUntilBreakpoint(); //advance to line 10
variables[0].push(session.view(data.current.identifiers.native));
session.continueUntilBreakpoint(); //advance to the end
Expand All @@ -80,7 +78,6 @@ describe("Reset Button", function() {
session.reset();

variables[1].push(session.view(data.current.identifiers.native));
session.addBreakpoint({ sourceId: 0, line: 10 });
session.continueUntilBreakpoint(); //advance to line 10
variables[1].push(session.view(data.current.identifiers.native));
session.continueUntilBreakpoint(); //advance to the end
Expand Down

0 comments on commit 49a9e7e

Please sign in to comment.