Code Monkey home page Code Monkey logo

ds-test's People

Contributors

0xphaze avatar asymmetric avatar brockelmore avatar d-xo avatar dbrock avatar flaque avatar mbrock avatar mds1 avatar moodlezoup avatar mrchico avatar nanexcool avatar nmushegian avatar rainbreak avatar sabnock01 avatar smartcontracts avatar tcoulter avatar tommyrharper avatar zeroekkusu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ds-test's Issues

Mark `fail()` function `virtual`

When writing tests and experimenting, sometimes it is beneficial to let fail() quit as soon as the first test fails. This helps debugging and avoid a lot of logs on screen.

Something like this

function fail() internal {
     revert();
}

Marking this function virtual allows us to update this function as necessary.

Crashes when calling a function with `assert` inside it

EtherToken.sol contract

Asset.t.sol tests

When I run dapp test -v I get this crash error in the output:

+ dapp quicktest -v out out/simpleAdapter.bin out/rewards.bin out/safeMath.bin
Secp256k1 bindings are not compiled. Pure JS implementation will be used.
Trying out/assets/AssetTest...
.F.

  [CRASH] testWithdraw
                                -> <out/assets/AssetTest#ee35>.testWithdraw() => BadInstruction
    <out/assets/AssetTest#ee35> ->   <out/assets/EtherToken#db93>.balanceOf(<out/assets/AssetTest#ee35>) => (1e+28)
    <out/assets/AssetTest#ee35> ->   <out/assets/EtherToken#db93>.withdraw(0.5 ether) => BadInstruction

2 tests passed, 1 failed
Took 0.200s

When I remove the assert on L45 here I don't get this crash.

Could it be something to do with overshadowing solidity's native assert function?

`assert` shadows the Solidity keyword

Just spent some time trying to figure out why the asserts in my test weren't getting triggered. "Crashes" have precedence over "assertion failures" in dapp, so all I was seeing was a "crash" from later in my code, rather than the "crash" was expecting from the asserts. It looked like assert(false) was failing to throw, which was driving me a little crazy for a second there.

"Unexpected end of JSON input" when running test

Running this file it fails on the linked line, when uncommented.

Output like this:

+ dapp quicktest out out/simpleAdapter.bin out/rewards.bin out/safeMath.bin                                                                                                                    
Secp256k1 bindings are not compiled. Pure JS implementation will be used.                                                                                                                      
Trying out/DataFeedTest, out/assets/AssetTest, out/datafeeds/DataFeedTest, out/participation/ParticipationTest, out/version/VersionTest...                                                     
....thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Invalid character '_' at position 47616', /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libcore
/result.rs:868                                                                                                                                                                                 
note: Run with `RUST_BACKTRACE=1` for a backtrace.                                                                                                                                             
undefined:1                                                                                                                                                                                    
                                                                                                                                                                                               
                                                                                                                                                                                               
                                                                                                                                                                                               
SyntaxError: Unexpected end of JSON input                                                                                                                                                      
    at JSON.parse (<anonymous>)                                                                                                                                                                
    at handleTestOutput (/home/travis/prg/dapp/libexec/dapp/dapp-quicktest:172:23)                                                                                                             
    at Socket.child.stdout.on (/home/travis/prg/dapp/libexec/dapp/dapp-quicktest:163:32)                                                                                                       
    at emitNone (events.js:110:20)                                                                                                                                                             
    at Socket.emit (events.js:207:7)                                                                                                                                                           
    at endReadableNT (_stream_readable.js:1059:12)                                                                                                                                             
    at _combinedTickCallback (internal/process/next_tick.js:138:11)                                                                                                                            
    at process._tickCallback (internal/process/next_tick.js:180:9)                                                                                                                             
thread 'main' panicked at 'failed printing to stdout: Broken pipe (os error 32)', /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/io/stdio.rs:693                     
note: Run with `RUST_BACKTRACE=1` for a backtrace.                                                                                                                                             
thread 'main' panicked at 'failed printing to stdout: Broken pipe (os error 32)', /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/io/stdio.rs:693                     
note: Run with `RUST_BACKTRACE=1` for a backtrace.                                                                                                                                             
thread 'main' panicked at 'failed printing to stdout: Broken pipe (os error 32)', /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/io/stdio.rs:693                     
note: Run with `RUST_BACKTRACE=1` for a backtrace.                                                                                                                                             
thread 'main' panicked at 'failed printing to stdout: Broken pipe (os error 32)', /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/io/stdio.rs:693                     
note: Run with `RUST_BACKTRACE=1` for a backtrace.                                                                                                                                             
thread 'main' panicked at 'failed printing to stdout: Broken pipe (os error 32)', /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/io/stdio.rs:693                     
note: Run with `RUST_BACKTRACE=1` for a backtrace.    

Not sure what this stack trace means exactly, but the Err value: Invalid character '_' at position 47616' makes me wonder whether it's due to some unlinked library (__libnameEtc__ still in the bytecode).

Just a guess though.

tests stall when calling function with dynamically-sized array as input

Am I doing something wrong?

e.g.

My.sol:

contract My {
    function myFunc(address[] addrs) returns (uint) {
        return 0;
    }
}

My.t.sol:

import "ds-test/test.sol";
import "./My.sol";

contract MyTest is DSTest {
    My contractInstance;

    function setUp() {
        contractInstance = new My();
    }

    function testFunc() {
        address[] addrs;
        addrs.push(this);
        contractInstance.myFunc(addrs); // hangs here
    }
}

$ solc --version
solc, the solidity compiler commandline interface
Version: 0.4.17+commit.bdeb9e52.Linux.g++

$ dapp --version
dapp 0.5.6

Consider adding a package.json file

It would be a massive improvement for compatibility with NPM if ds-test had a package.json file. This would make it possible to import ds-test as a GitHub dependency without npm install breaking. This would not require actually publishing ds-test to NPM or dealing with the NPM ecosystem beyond just including the one file. forge-std recently made this addition, for what it's worth.

See here for the package.json that forge-std added for reference: https://github.com/foundry-rs/forge-std/blob/master/package.json

Allow for equatlity assertion with tiny margin of errors

Could we add equality assertions that allow for very tiny deviations (due to rounding of different order of fixed math lib operations in expected test values vs source code values) which would be specified in the assert function signature?

For example something like this:

function assertEqWithDeviation(
    uint256 a,
    uint256 b,
    uint256 allowedDeviation
) internal {
    if (a != b) {
        if (a > b) {
            if (a - b > allowedDeviation) {
                fail();
            }
        }
        if (a < b) {
            if (b-a > allowedDeviation) {
                fail();
            }
        }
    }
}

Repo git clone fails on Windows

Hi! Cloning this repo fails on Windows because one of the directories is called aux. aux is a reserved file name and one can't create a file or dir with this name under any circumstances.

Git yields an invalid path error and the clone fails.

I know that this is very stupid and should really be considered a bug in Windows. Having said this, to the best of my understanding, this makes it all but impossible to even save a full copy of the DAI source code on Windows, which may not be ideal from an inclusiveness standpoint.

That's why I suggest to rename the aux directory to something else, as ridiculous as it may be.

As far as I'm aware, there are only two workarounds for Windows users:

  1. Using a linux virtual machine, with all the inconveniences that come with that.
  2. One can use clone from a git instance that is installed into the Windows subsystem for linux as a linux package. However, actually using this cloned repo from Windows leads to all kinds of issues. (e.g. I can't explore the 'aux' directory from my text editor, I can't 'cd' there, no completion, etc.)

Note in particular that setting core.protectNTFS=false in git does not help.

Add ds-test as NPM modules for Hardhat backwards compatibility

Describe the feature you would like

Issue described in detail here.

Many of use would like to use Foundry + Hardhat, which still has tons of use cases (integration testing, complex deployment scripts, etc) and should really not be treated as a direct competitor. However, there are some small inconveniences that we have found when trying to do this.

As shown in the issue, it can almost be tidied up into one source of truth for all dependencies by mapping the paths the Forge uses to node_modules. But since ds-test and forge-std do not have NPM modules, you still need to maintain a ./lib directory and remappings.txt.

The simplest fix would probably be to wrap these dependencies in NPM modules. This probably has use-cases outside just the one described above, but would help immensely for all the Hardhat folks that want to give Foundry a go.

forge-std will do this but they need help with ds-test NPM package: foundry-rs/forge-std#39 (comment)

Thanks! ๐Ÿ™

Create releases / tags to properly import to forge for future-proofing repos

Currently, there are no releases or changelog for DS-Test which when pulling in the latest version of DS-Test can break repos especially when using main-tracked submodules with forge/foundry.

This is a suggestion to add a CHANGELOG.md file and create releases for breaking changes that allow users to install versioned release tags for future-proofing repos.

Warning: Invoking events without "emit" prefix is deprecated

This is for new solc compiler (after updating with nix-channel).

solc version

 solc --version
solc, the solidity compiler commandline interface
Version: 0.4.21+commit.dfe3193c.Linux.g++

A bunch of warnings when building

~/ds-test$ make
dapp build
+ dapp clean
+ rm -rf out
+ solc --overwrite --abi --bin --bin-runtime = -o out/ src/test.sol
src/test.sol:44:9: Warning: Invoking events without "emit" prefix is deprecated.
        eventListener(target, true);
        ^-------------------------^
src/test.sol:51:9: Warning: Invoking events without "emit" prefix is deprecated.
        log_named_uint("gas", startGas - endGas);
        ^--------------------------------------^
src/test.sol:56:13: Warning: Invoking events without "emit" prefix is deprecated.
            log_bytes32("Assertion failed");
            ^-----------------------------^
src/test.sol:63:13: Warning: Invoking events without "emit" prefix is deprecated.
            log_bytes32("Error: Wrong `address' value");
            ^-----------------------------------------^
src/test.sol:64:13: Warning: Invoking events without "emit" prefix is deprecated.
            log_named_address("  Expected", b);
            ^--------------------------------^
src/test.sol:65:13: Warning: Invoking events without "emit" prefix is deprecated.
            log_named_address("    Actual", a);
....

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.