Questions tagged [remix-tests]
remix-tests is a tool by Ethereum Remix Team which can be used for Solidity Unit Testing.
37
questions
0
votes
0
answers
10
views
getting error while calling getrandomnumber in my smart contract
error message: Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending?
execution reverted { "originalError": {...
1
vote
1
answer
35
views
Testing external functions in Remix
I am writing unit tests on Remix (using Solidity Unit Testing) for my contract. However, I am having trouble testing external functions when msg.sender is involved.
The contract:
pragma solidity 0.8....
0
votes
1
answer
27
views
How do I test extra parameters in Remix?
I tried to use Remix to test a Smart Contract:
/********************************************************************
* Make bids with ETH or an ERC20 Token specified by the NFT seller.*
* Additionally,...
0
votes
0
answers
7
views
Trouble deploying an ERC20 contract remix
Hi so some assistance would be greatly appreciated. I am able to successfully deploy my contract when my ether is set to 0. It will go through MM and everything looks solid. By the way I am using test ...
0
votes
0
answers
14
views
Solidity unit tests using Remix unit_tests plugin
I have a 2 contracts
Token A - Basic ERC20 Token
Token B - An ERC20 Token which takes Token A
My question is more on solidity UNIT_TESTS plugin. From my understanding, I can only manipulate msg....
0
votes
0
answers
34
views
Is it possible to import multiple contracts inside a remix test and pass an ERC20 address?
I want to run unit tests in remix where I have 2 contracts Token A (AUSDC) that will be exchanged for Token B (AToken)
However, during the imports, I am shown the ff: error
import "../contracts/...
0
votes
0
answers
13
views
What is the unit of REMIX UNITTEST NatSpec #value
I am running unit tests on REMIX and would like to confirm what the unit is for the #value: X when sending msg.value?
/// #sender: account-7
/// #value: 2
function buyToken () public payable {
...
1
vote
0
answers
41
views
How to run a REMIX UNIT TEST for 2 Smart Contracts (Token Contract and Staking Contract)
I have 2 Smart Contracts
Token Contract: A basic ERC20 with 6 decimals
Staking Contract: A contract which locks in the Token above and requires the Token address to be part of the parameters
I am ...
0
votes
1
answer
29
views
I can't figure out why my test dont pass
I always get this an error when i run my test, i dont know what to do anymore
you can test at my repository on github here
0
votes
2
answers
72
views
How can I pass an amount with the gas fee and msg.value in solidity unit test
Id like to test this function of buyTokens but i can't figure out how to pass the amount of tokens as argument
This is the test contract
Function to be tested
0
votes
1
answer
104
views
chainlink oracle http get request not returning value - taken from example but still is not working
I have my own oracle code that suddenly stopped returning any output. So I double checked with the official Chainlink oracle example on remix and that is also not returning any value...
I have sent ...
0
votes
0
answers
62
views
Transaction successfull on metamask ,NFT won't show on opensea and Remix still on pending
I've made a new smart contract to mint my NFT and just made a transaction: https://explorer.testnet.rsk.co/tx/0xb4981712e54975b21bb868e1df8fb7d973587d9fb091a5cfb7c85383ec8f5fdf?__ctab=Transaction
...
1
vote
1
answer
45
views
Unexpected "catch Error" Behavior
IDE: Remix (on Firefox and Brave)
Compiler: v0.8.12
I am practicing with unit tests on the Ballot sample contract from Solidity's documentation, and am having trouble understanding how does catch ...
0
votes
0
answers
37
views
constructor { manager = msg.sender} reverting while deploying
so i have a contract
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract Lottery{
address public manager;
address[] public players;
constructor(){
manager = msg.sender;...
0
votes
1
answer
34
views
Why does my mint function throw an insufficent amount error?
I'm testing a smart contract on REMIX, everything works but the mint function provided throws an insufficient amount error even though I have enough ether in my account.
It seems like theirs no ether ...
0
votes
1
answer
75
views
How to write Test case for NFT buy functionaity?
Function for buying NFT
function buy(address nftContract, uint256 itemId)
public
payable
nonReentrant
{
uint256 price = idToMarketItem[itemId].price;
uint256 tokenId = ...
1
vote
1
answer
77
views
What to pass for abi encoded arguments
I had cloned usdc contract on polygon test network and deployed it. I want to test deposit method but couldn't able to figure what to pass in depositData( more specifically in which format should i ...
0
votes
1
answer
26
views
Remix's documented test test#2 fails
Why the remix’s documented test#2 fails?
Hi,
I am following the remix’s example test available at:
https://remix-ide.readthedocs.io/en/latest/unittesting_examples.html.
The sender code is:
pragma ...
0
votes
1
answer
21
views
Testing the Remix example2 contract
I am trying to execute the remix test#2 at:
Testing the Remix example contract#2
But I am gettig the error:
tests/senderTest_test.sol:33:22: DeclarationError: Undeclared identifier.
Assert.equal(...
1
vote
1
answer
241
views
TypeError: Member "push" not found or not visible after argument-dependent lookup in address payable[] storage ref
I am having the above error at the point where I am pushing the newly created contract address into the contracts[] array. Where am I going wrong? Any help will be appreciated.
pragma solidity ^0.8.0;...
0
votes
0
answers
100
views
Remix: Test Failed and the Message is " Transaction is reverted"
I am sending ETher from the test contract and then checking the balance but I am getting the message, Test Failed and Transaction is reverted.
My contracts are:
//pragma solidity >=0.4.22 <0.9.0;...
0
votes
0
answers
152
views
Contract Deployment on Remix in JavaScript VM pending indefinitely
https://youtu.be/M576WGiDBdQ?t=6082
I'm writing code along with this YT tutorial to learn Solidity with Remix. I cannot deploy the contract, it shows "creation of SimpleStorage pending..." ...
0
votes
2
answers
87
views
Whats needed to complete my contract token for this BEP20?
I'm trying to figure out if the 80% of the total supply is allocated to the network? and if there are any fundamental things I am missing here?
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
...
0
votes
1
answer
263
views
My remix.eth page does not connect with my metamask account
When I choose the "injected web3" environment metamask does not automatically
pop-up,thus I have to manually connect my metamask account with the remix.eth web page.However when I do this ...
0
votes
0
answers
20
views
why does any contract i write to the blockchain look like this
ive tried about 40 different contracts and they all do not show as a token, ive tried bsc,bsctestnet, pulsechain testnet.
when i try to verify the code on bscscan it says the byte code doesnt match
it ...
0
votes
0
answers
1k
views
How to send the ERC721 NFT token of existing smart contract to another wallet using my smart contract
I have some ERC721 NFTs in my wallet minted in A smart contract.
I want to transfer that NFTs to another wallet using my smart contract.
But I am getting error like: "ERC721: approve caller is ...
0
votes
1
answer
84
views
I can't compile, on my library SafeMath it says "parsererror: function, vairable, struct or modifier declaration expected, please help me
pragma solidity ^0.8.2;
contract Token {
mapping(address => uint) public balances;
mapping(address => mapping(address => uint)) public allowance;
uint public totalSupply = ...
0
votes
1
answer
1k
views
How to call a fallback function in remix
I have the below code in remix. I remember the remix had the "fallback" button to check the fallback method. I am back after long time. I do not find the "fallback" button. I ...
1
vote
0
answers
366
views
Gas estimation failed in remix with MATIC or BSC (ETH testnet works)
I'm facing a very annoying error but I'm unable to find an answer for it.
Case:
Using Metamask, having accounts in eth Popsten with ETH coins, bsc and matic with coins
I'm using just a simple ...
1
vote
1
answer
153
views
Unit test on remix keeps throwing typeError
I am trying to write a unit test for my token contract whose constructor takes 6 arguments. I have written the test but each time I try to test any function on the token contract it throws TypeError ...
0
votes
2
answers
1k
views
Solidity Smart Contract - Split and Send Contract ETH Balance Between Two Accounts
Want to start off by saying thanks in advance. I'm very new to solidity, so really appreciate your time.
I've built a basic smart contract for testing purposes, and I'm running it on Remix.
I want to ...
0
votes
2
answers
70
views
Remix says that I got undeclared variable in my test contract when trying to run it, when it is declared in the original contract. How to fix?
Basically I need to get the hash from the function in the original contract, and for that the function makeBet() requires some input. The function looks like this:
pragma solidity >=0.8.0 <0.9.0;...
1
vote
1
answer
2k
views
How to properly write Solidity unit tests?
I would like to write maintainable and readable unit tests for my code. Requirements:
Test different actors. E.g. a bank contract and three customers interacting with it.
Test for errors. E.g. test ...
1
vote
0
answers
25
views
Remix Unit Testing: Fail message is giving wrong name of the test file
I am trying to do unit testing using Remix using the tutorial at Simple Contract at Medium, but it is giving me a FAIL message with “browser/tests/4_Ballot_test.sol) file highlighted with blue ...
0
votes
1
answer
259
views
The called function should be payable if you send value and the value you send should be less than your current balance. WITH NON-Payable functions
I have the following functions
function balance() public view returns(uint152) {
return uint152(IERC20(token).balanceOf(address(this)));
}
function balance1() public view returns(...
0
votes
0
answers
232
views
Empty msg.sender in contract function when called from Remix testing
I have a very simple contract function (bogusFunc) that makes use of the implicit msg.sender:
function bogusFunc(uint256 _val) public
{
// use _val for something
user_list.push(msg.sender);
}
...
1
vote
1
answer
872
views
How do I simulate multiple users in a remix unit test?
In the following example, I want to test the assignVoter functionality with Remix unit test plugin. assignVoter should only be called by the owner.
pragma solidity >=0.4.22 <0.7.0;
contract ...