Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 18 18:57
    fainashalts review_requested #3707
  • Jan 18 18:54
    fainashalts ready_for_review #3707
  • Jan 18 18:54
    fainashalts synchronize #3707
  • Jan 18 18:54

    fainashalts on addImmutableReferences

    Add immutableReferences to byte… Add immutableReferences to test… Add basic integration test and 5 more (compare)

  • Jan 18 18:17
    fainashalts edited #3707
  • Jan 18 18:17
    fainashalts edited #3707
  • Jan 18 18:11
    fainashalts edited #3707
  • Jan 18 18:08
    fainashalts synchronize #3707
  • Jan 18 18:08

    fainashalts on addImmutableReferences

    Remove immutableReferences from… Add immutableReferences type to… Add immutableReferences to comp… and 2 more (compare)

  • Jan 18 16:32
    cjfarnold opened #3711
  • Jan 17 14:19
    SvenMeyer commented #3539
  • Jan 17 13:54
    cds-amal commented #3539
  • Jan 17 10:04
    SvenMeyer commented #3539
  • Jan 17 09:57
    SvenMeyer commented #3539
  • Jan 16 15:48
    vittominacori opened #3710
  • Jan 15 14:58
    eggplantzzz review_requested #3703
  • Jan 15 14:58
    eggplantzzz review_requested #3703
  • Jan 15 14:58
    eggplantzzz review_requested #3703
  • Jan 15 14:58
    eggplantzzz review_requested #3703
  • Jan 15 14:34
    rkalis synchronize #3709
tyler
@eggplantzzz
No you can just just test the return values of the functions if you write your tests in Solidity.
Greg Solovyev
@grishick
does truffle debugger actually work for "view" functions? I don't seem to be able to get it to stop on debug() statement. Instead, it just keeps failing the call in side that statement with "Error: Returned error: VM Exception while processing transaction: revert".
eu777
@eu777
@eggplantzzz I read this doc, but it didn't really help me. I'm going to retry.
Does someone know how fully configure IntelliJ with Solidity? I'm struggling with this (e.g image). Between, compilation works with this command line "truffle compile"
Jhomar Maravillas
@jmarrr

How do I keep the fork mainnet use the latest block using web3?
I need to fork mainnet to latest block before I send the transaction
What originally i do is just run the ganache fork command which only have the state the block the time i ran it and use.

// at some conditions
const localWeb3 = new Web3( // connect to forked net
    new Web3.providers.WebsocketProvider('ws://localhost:8546') // port of forked mainnet ganache
)
// do the transaction

What I tried

// at some conditions
const localWeb3 = new Web3( // connect to forked net
    ganache.provider( {fork: "myalchemyprovider"} ) 
// do the transaction

or with
    ganache.provider( {fork: web3.currentProvider} ) // no good since i dont have archive mode of eth node

what is the correct way to do this?

tyler
@eggplantzzz
@eu777 If you have a specific question then perhaps I can answer it to give you something to start with. Can you ask one?
I could give you an example of how to test one of your contract's functions maybe? Would that help?
For example in your contract, you could instantiate a new Candidate and set the percent. You could then import the Truffle Assert library to assert that getPercent returns the value that you set it at.
QP
@theqp
is there any way to chache sol files so only recompiled when the sol file is changed?
tyler
@eggplantzzz
Normally Truffle should only recompile your artifacts if something has changed.
Are you talking about normally while running truffle compile?
So what I'm saying is Truffle should already not compile Solidity that hasn't changed
QP
@theqp
i am talking about truffle test
tyler
@eggplantzzz
Truffle does compile your Solidity tests every time because artifacts are not created for those test files.
But it shouldn't compile your other files in the contracts folder unless it sees that the generated artifacts are older than the last modification of your source files.
Does that make sense?
QP
@theqp
oh, now i noticed, if i run truffle compile before tests then test does not need to compile the contract
tyler
@eggplantzzz
Yes! The other thing of note is that during truffle test, artifacts for you contracts are not saved.
So if your artifacts are out of sync, they will compile every time you run truffle test because they will be out of date every time
So running compile when you update makes sense and will save you some time while running the Solidity tests
ccolorado
@ccolorado

Is there a recomendation for how to handle contracts with multiple solc verisons (e.g . I have a copy of the dai contract that is on 0.5.11, but my app is on 6+.
Is there any practical way to handle this?

Deploying the token once in each network sounds reasonable until you start thinking how cumbersome to manage a local blockchain like ganache

g. nicholas d'andrea
@gnidan
@ccolorado follow this PR trufflesuite/truffle#3704
ccolorado
@ccolorado
thanks
g. nicholas d'andrea
@gnidan
np! don't have a good hacky way to do it in the meantime (you might be able to leverage the truffle external compiler system, but I don't have a writeup or anything. I know someone else has done this before)
ccolorado
@ccolorado
cool, thanks I'll take a look
zaekona
@zaekona
Hi all. I am using vue-box and Ganache, but for some reason when running migrate the ERC20 contract and some others are not deploying but the example ones are. Any advice?
Kirill69-666-66-69
@Kirill69-666-66-69
Hey folks, this seems to be problem from 2018
unsure what I am doing it wrong

I have installed latest ganache-cli(6.12.2) and by using remix, I have deployed "King of the Ether" contract (here: https://docs.soliditylang.org/en/v0.8.0/common-patterns.html)

When I deploy the contract and call "becomeRichest" function, I get "Gas estimation failed" error

I have tried with Javascript VM, Injected Web3(Metamask > localhost hooked to ganache) and Web3 provider being ganache-cli itself

fsd.png
eu777
@eu777

I could give you an example of how to test one of your contract's functions maybe? Would that help?

Having an example would help me a lot! Here's an example of what I did for the moment https://imgur.com/a/knizFKb

image.png
eu777
@eu777

@eu777 If you have a specific question then perhaps I can answer it to give you something to start with. Can you ask one?

My question is how to test properly my Candidate file. I suppose that I have to test my computeAverageNote function but I don't realluy know how to do it

tyler
@eggplantzzz
So it looks like you're off to a good start. Currently you don't set the value of the variable percent in your contract and you don't have a way of setting it. You should probably either set it in your constructor or create a function to set it.
If you are testing getPercent then your test would roughly look something like
function testGetPercent () public {
  candidate.setPercent(40);
  uint result = candidate.getPercent();
  Assert.equal(result, 40, "The percent should be set to 40.");
}
So you would use your setter function to set the percent. You would then expect that your getter would return the same number.
That is a simple example. If you wanted to test another function you need to do something similar, asserting that given some starting values and some input, you would expect very specific output. Does that help?
tyler
@eggplantzzz
But do note that those variables percent and choiceCount are found on the contract.
"found on the contract"
Meaning that you need to access them through the contract
Jhomar Maravillas
@jmarrr

I am having hard time to run make the fork work when i use ganache provider

I am trying to run a method and the return is stuck on promise pending, if i have to do await it still stuck waiting for return. I have no idea why this happen, i log the value of localWeb3 and it returns an object without a problem

There is the snippet:

txChecker = async () => {
const localWeb3 = new Web3(
      ganache.provider({ fork: "wss://eth-mainnet.ws.alchemyapi.io/v2/apikey" })
    )

console.log(localWeb3) // image attached

console.log("latest_block forked 1: ", localWeb3.eth.getBlockNumber()) // promise state pending, value undefined

console.log("latest_block forked 2: ", await localWeb3.eth.getBlockNumber()) // black
}

Anyone help me please.

eu777
@eu777
Thank you @eggplantzzz it helped me a lot!
Jhomar Maravillas
@jmarrr
It seems that ganache-core doesnt work correctly with reactjs/dapp. Is this intended behavior? anyone can confirm?
steelep
@steelep

Hi - I am trying to simulate a transaction in a forked web3 environment via ganache-cli, I can do everything fine, except the "confirmation" event is never triggered, I can receive errors & receipts. How can I get the confirmation event as specified in the docs? ```
async function dryRun(_transaction){
var localWeb3 = new Web3(ganacheCLI.provider({fork: productionServer, port:7535, unlocked_accounts: [_transaction.from]}))
var sentTx = localWeb3.eth.sendTransaction(_transaction)

.once('receipt', function(receipt){
    console.log("Msg Receipt: ",  _transaction.hash);
})
.on('confirmation',  function(confirmationNumber, receipt){
    console.log("Confirm: ", _transaction.hash, confirmationNumber, receipt);
})
.on('error', function(error){ 
    console.log("Error", _transaction.hash, error.message);
})

}
```

I understand, the ganache-cli instance should automine the transaction immeadiately and fire back a confirm? Let me know what im doing wrong! Cheers
(Sorry for the formatting issue)
ML
@mlntr
truffle test runs fine, but is there a way to prevent 'artifacts' is not defined in my test file? (maybe import something or a setting?) it blocks VSCode Mocha test explorer from working
steelep
@steelep
Figured my question out... Thanks