Questions tagged [assert]

An assertion is a statement, which aborts a program when it evaluates to false. Assert is typically used for debugging and situations which should never happen.

Filter by
Sorted by
Tagged with
0
votes
1answer
20 views

I want to understand something with BigNumber assertions

I have create a truffle project with a smartcontract and a test file. Here is an extract of the test file: expect(ret).to.be.bignumber.equal(new BN('42')); ret is a value returned by a smartcontract'...
0
votes
1answer
18 views

Truffle console: assert.equal, how to use exception for testing purposes?

I want to check the value returned by getName() function: pragma solidity >= 0.5.0 < 0.7.0; contract SimpleContract { string public name; constructor() public { name = 'abs'; } ...
0
votes
0answers
22 views

Are assertions removed in release build?

Are assert() removed in release build? Please show an authoritative document documenting that they are removed or no removed.
1
vote
2answers
174 views

Read message of require / revert statement in app.js

In my App.js I have called the smart contract function and the require statement in the function is not satisfied, so how do I get the message of that require statement in my App.js?
2
votes
1answer
302 views

How to handle require/revert/assert errors properly

I'm trying to find an easy pattern to revert/rollback a write transaction. The first idea was to log a GenericErrorEvent but then I noticed that it will never be emited if any require/revert/assert ...
3
votes
1answer
130 views

Access require message

I am using JavaScript to run some tests on my solidity contract. Since solidity ^0.4.22 you can have a message in require such as: function Hello { require(msg.sender == 0x001234, "msg.sender ...
1
vote
1answer
254 views

How to use require() with stings

I am trying to run this code on remix IDE: pragma solidity ^0.4.24; contract Aa { string public result; function feedData(string _result) public { require(_result = "e" , "...
3
votes
1answer
37 views

Contract design by contract -> correctness and maximum gas consumption

This question is a general design question that regards contract correctness and the functions I list here are just examples. As I develop on Ethereum, it becomes aparent to me that it might be ...
1
vote
1answer
472 views

Better ways to test bytes32 type using truffle testing framework

small quick question, when I store a bytes32 and retrieve it from truffle console, why is it showing in 64 bits? Ex: 0x74657374737472696e6700000000000000000000000000000000000000000000 because this ...
4
votes
2answers
601 views

Why not use require() in place of assert()?

Even though require() is used substantially more than assert(), there are places where assert() gets used. One example would be in the widely adopted SafeMath library by OpenZeppelin: function add(...
1
vote
1answer
290 views

Handling require/assert failure errors correctly from a Node.JS app?

I have a getter function in my smart contract that returns one of the string values in statically defined string array. Upon entry to the function, it does a bounds check on the incoming index using ...
3
votes
1answer
195 views

Call a zero-initialized variable of internal function type

I was reading solidity documentation about when an assert-style exception is generated. In the 6th point it says: "If you call a zero-initialized variable of internal function type." I don't ...
0
votes
1answer
137 views

Issue with Assert statement in solidity

I am probably missing something very obvious but I cannot get the simplest assert statement to work! What am I doing wrong? My goal is to simply confirm that I am within a start date and end date ...
0
votes
1answer
695 views

Remix Warning : Assert

I am trying to compile a contract on remix and have run into the following warning : Use assert(x) if you never ever want x to be false, not in any circumstance (apart from a bug in your code). ...
0
votes
1answer
134 views

'Assert' and 'require' atomicity while internally calling another contract

contract one{ unint number; function saveNumber(unint _number){ number = _number; } } contract two{ function callOtherFunctionAndAlsoTransferFunds(){ oneContract = one('contractaddress'); ...
0
votes
1answer
297 views

Control structure with truffle (assert and require)

When I'm trying to deploy contracts that contain assert and require using truffle I receive Error: Undeclared identifier. e.g: pragma solidity ^0.4.8; contract Owned{ address public owner = ...