Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add buttons to deploy a contract that will always fail when sending a transaction to it #135

Open
danjm opened this issue Nov 15, 2021 · 1 comment
Assignees

Comments

@danjm
Copy link
Contributor

danjm commented Nov 15, 2021

We need our test dapp to be able to test error cases. A basic error case that we need to add is a transaction with a smart contract, which will always fail because of a condition internal to the smart contract code.

Here is the code for a smart contract. Transactions sent to this contract will always fail if the value of the transaction is less than 0xfff

pragma solidity 0.5.12;

contract MMCheck {

    function() external payable {
        assert(msg.value > 0xfff);
        msg.sender.transfer(msg.value);
    }
}

The following code would create a transaction to deploy this contract:

var mmcheckContract = new web3.eth.Contract([{"payable":true,"stateMutability":"payable","type":"fallback"}]);
var mmcheck = mmcheckContract.deploy({
     data: '0x6080604052348015600f57600080fd5b50608b8061001e6000396000f3fe6080604052610fff3411600e57fe5b3373ffffffffffffffffffffffffffffffffffffffff166108fc349081150290604051600060405180830381858888f193505050501580156053573d6000803e3d6000fd5b5000fea265627a7a72315820631b0dbb6b871cdbfdec2773af15ebfb8e52c794cf836fe27ec21f1aed17180f64736f6c634300050c0032', 
     arguments: [
     ]
}).send({
     from: web3.eth.accounts[0], 
     gas: '4700000'
   }, function (e, contract){
    console.log(e, contract);
    if (typeof contract.address !== 'undefined') {
         console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);
    }
 })

We need to add a section to the test dapp that has two buttons, one to deploy this contract and one to send a transaction to it.

Acceptance criteria

  • add a new section to the "Send Eth" card in the test dapp. Add a new <hr> below the current "Contract" section, the section can be very similar to the "Contract" section, except that it should have a new title "Failing Contract", and two buttons: "Deploy Failing Contract" and "Send Failing Transaction"
  • clicking the "Deploy Failing Contract" button should call code very similar to the current "Deploy" button code, but instead should deploy the contract data 0x6080604052348015600f57600080fd5b50608b8061001e6000396000f3fe6080604052610fff3411600e57fe5b3373ffffffffffffffffffffffffffffffffffffffff166108fc349081150290604051600060405180830381858888f193505050501580156053573d6000803e3d6000fd5b5000fea265627a7a72315820631b0dbb6b871cdbfdec2773af15ebfb8e52c794cf836fe27ec21f1aed17180f64736f6c634300050c0032
  • clicking the "Send Failing Transaction" button should send a transaction with value 0x0 to the address of the new contract (the way that "Deposit" creates a transaction to the address of the contract created by "Deploy")
  • if done correctly, the transaction created by "Send Failing Transaction" should show an error message, but you should still be able to submit it. However, after submission, it should fail
@EHaracic
Copy link

AC:

  • The second button ("Deploy Failing Contract") should be initially disabled. Once the Contract has been deployed the button will enabled

@EHaracic EHaracic self-assigned this Nov 16, 2021
@dragana8 dragana8 assigned dragana8 and unassigned EHaracic Nov 22, 2021
@dragana8 dragana8 assigned ghost and unassigned dragana8 Nov 29, 2021
@ghost ghost assigned dragana8 and unassigned ghost Nov 30, 2021
danjm pushed a commit that referenced this issue Dec 9, 2021
… transaction to it #135 (#139)

* added buttons

* changed label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants