2

General problem:

Using double linked list. Because of block gas limits, I call a function off-chain to find the exact insertion point.

Code:

function bid(uint insertionBidId) public payable {
    emit LogText("derived class (multiple)");
    ...
}

https://github.com/genesisdotre/ethereum-auction/blob/no-limit/contracts/AuctionMultiple.sol#L64

Tests:

var insertionPoint = await auction.searchInsertionPoint.call(2.6e18, tailBidId, { from: bidderE });
console.log(insertionPoint);
var tx = await auction.bid(insertionPoint, { value: 1e18, from: bidderE });

https://github.com/genesisdotre/ethereum-auction/blob/no-limit/test/AuctionMultiple.js#L472


Error: Invalid number of arguments to Solidity function

I have no idea what is wrong.

This runs till the end

var tx = await auction.bid({ value: 1e18, from: bidderE });

(using bid function from the base class that does not require parameter)

  • Try changing tfrom to from – Raghav Sood Aug 2 '18 at 14:33
  • @RaghavSood good spot, tried that, same thing... Will edit the question. – Mars Robertson Aug 2 '18 at 14:49
1

Since AuctionMultiple is Auction, and both of them define a function called bid (with a parameter in AuctionMultiple, and without one in Auction), you end up with the following abi:

[  
   {  
      constant:false,
      inputs:[  

      ],
      name:'bid',
      outputs:[  

      ],
      payable:true,
      stateMutability:'payable',
      type:'function'
   },
   {  
      constant:false,
      inputs:[  
         Array
      ],
      name:'bid',
      outputs:[  

      ],
      payable:true,
      stateMutability:'payable',
      type:'function'
   }
]

Now, for whatever reason, web3 (or maybe truffle) decides to only follow the first abi, and not the second one. This gives an invalid argument error, since it isn't expecting any arguments.

By renaming bid to bid2 in AuctionMultiple, I was able to get your test to run. It still reverts, but at least it runs.

| improve this answer | |
  • Can I have my ___ hours back? Test fails due to copy-paste error, calculating position for 2.6 ETH and then sending 1 ETH. I'll simplify the test case and report bug to Truffle? – Mars Robertson Aug 2 '18 at 19:56
  • @MichaelFreeman I would report it, but I'm not sure if it is actually a bug. Javascript does not support function overloading, so two functions with the same name but different args would be hard to work with. Note that this won't cause issues in your contract, since they will have different signatures. You could write a test and keep the same name by encoding the msg.data manually, with the appropriate function signature for bid(uint256) – Raghav Sood Aug 3 '18 at 0:17
  • "encoding the msg.data manually" + appropriate function signature for bid(uint256) = something like encoding raw transaction... Interesting concept, it's just adds complexity, I want things to work ! ! ! – Mars Robertson Aug 3 '18 at 6:22
0

Truffle (v5; not released yet) supports function overloading in testing via JS.

yarn add truffle@next

Though I'm experiencing other issues with this unreleased version, so I cannot recommend upgrading just yet.

| improve this answer | |
  • 1
    Been to DEVCON4? :) – Mars Robertson Nov 2 '18 at 10:19
  • I was supposed to go as I had my ticket and everything. But I had to cancel my trip out there due to catching the flu right beforehand :( – Matt Swezey Nov 3 '18 at 14:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.