question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Arbitraries/Examples for Solidity/Ethereum types

See original GitHub issue

💬 Question and Help

Hi! Im interested in implementing fast-check for smart contract testing, allowing me to randomly create values to test different sets of functions and parameters in our smart contracts in Solidity.

Are there any examples or types that are already prepared for this that I can reuse? (like creating addresses, valid amounts, etc all compatible with Solidity/Eth types). Specifically we are using ethers.js in our case.

A possible amount could be uint256 which max amount is : 2**256 - 1. We have to use a BigNumber library for this and I don’t see that being supported in fast-check right?

Any help would be appreciated. Would love to be able to use this. Thanks!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
dubzzzcommented, Sep 24, 2021

You probably want to do that:

   it.only('Should transfer tokens correctly', async function () {
      await fc.assert(
        fc.asyncProperty(fc.bigUintN(256), async (amount) => {
          // Mint some tokens to the caller contract
          await token.mint(caller.address, amount)

          // Transfer
          await caller.safeTransfer(addr1.address, amount)
          expect(await caller['getBalance(address)'](addr1.address)).to.equal(amount)
          expect(await caller['getBalance(address)'](caller.address)).to.equal(0)
        })
      )
    })
0reactions
julianmrodricommented, Sep 28, 2021

Ideally I could do the clean-up by resetting the mocha/waffle context to the one before that single test executed. But couldn’t find a way to do that. Mocking the blockchain is what im doing in the “Model” (yes im doing Model Based testing which is quite suitable for my use case). So my real test needs to be with the actual blockchain.

Do you know if mocha provides a way to reset the context of a test which I could trigger in the afterEach for example?

Thanks for all your support!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Types — Solidity 0.8.17 documentation
Types . Solidity is a statically typed language, which means that the type of each variable (state and local) needs to be specified....
Read more >
Solidity Cheatsheet and Best practices - Manoj
This document is a cheatsheet for Solidity that you can use to write Smart Contracts for Ethereum based blockchain. This guide is not...
Read more >
HackPedia: 16 Solidity Hacks/Vulnerabilities, their Fixes and ...
This blog was written by Dr. Adrian Manning in this SigmaPrime Blog. If you are interested in IPFS, Libp2p, Ethereum, Zero-knowledge Proofs, DeFi, ......
Read more >
Contracts Calling Arbitrary Functions - Program the Blockchain
In this post, I'll show how smart contracts can use low-level message passing to make arbitrary calls into other contracts. I'll use this ......
Read more >
101 Smart Contracts and Decentralized Apps in Ethereum
Smart contracts are a new way to build decentralized applications in a Blockchain.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found