concept bidding in category blockchain

appears as: bidding
Blockchain in Action

This is an excerpt from Manning's book Blockchain in Action.

  • Data elements (listing 5.3)
  • Download the blindAuctionTest.js from the codebase of this chapter, and examine its content. Let’s examine one it() of the describe() for the bidding phase to understand how to define and code the describe() test:

    describe('Bidding Phase.', async ()=>{
        it('Success on single bid.', async function () {
          // Before bidding
          let balanceBefore = Number(web3.utils.fromWei(await 
                        (web3.eth.getBalance(ACC1), 'ether')); 
          // Bidding
          let bidInWei = web3.utils.toWei(String(BID1), 'ether');
          let valueInWei = web3.utils.toWei(String(BID1+1), 'ether');
          let hashValue = web3.utils.keccak256(..);
          await blindAuction.bid(hashValue, {from: ACC1, value: valueInWei});
          // After bidding
          let balanceAfter = Number(web3.utils.fromWei(await 
                             web3.eth.getBalance(ACC1), 'ether'));
          assert.isAbove(balanceBefore - balanceAfter, BID1+1);
          assert.isBelow(balanceBefore - balanceAfter, BID1+2);});