Giter Club home page Giter Club logo

delegatecall's Introduction

Testing delegate call in solidity.

Pre-requisite

node 8.4.0
truffle 3.4.5

steps

$ npm install
$ npm test

Result of test

> node test.js

Compiling ./contracts/Custody.sol...
Compiling ./contracts/Migrations.sol...
Compiling tokens/HumanStandardToken.sol...
Compiling tokens/StandardToken.sol...
Compiling tokens/Token.sol...

  Contract: deposit
    1) user is able to send tokens to custody contract
    Events emitted during test:
    ---------------------------

    Transfer(_from: <indexed>, _to: <indexed>, _value: 100)

    ---------------------------

  0 passing (290ms)
  1 failing

  1) Contract: deposit user is able to send tokens to custody contract:

      Error: expected 0 to sort of equal 100
      + expected - actual

      -0
      +100
      
      at Assertion.assert (node_modules/expect.js/index.js:96:13)
      at Assertion.eql (node_modules/expect.js/index.js:230:10)
      at Context.<anonymous> (test/custody.js:21:57)
      at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:188:7)



npm ERR! Test failed.  See above for more details.

Scenario:

I am trying to make use of delegatecall function in solidity. File name Custody.sol

    function delegateTokens(uint256 _value) returns (bool result) {
        tokens[msg.sender] = _value;
        return token.delegatecall(bytes4(sha3("transfer(address,uint256)")), address(this), _value);
    }

There is no error thrown but values are not changed.

delegatecall's People

Contributors

nirmalgupta avatar

Watchers

 avatar

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.