Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

When i run truffle test following errors occure #3962

Closed
1 task
coderbang1 opened this issue Apr 3, 2021 · 9 comments
Closed
1 task

When i run truffle test following errors occure #3962

coderbang1 opened this issue Apr 3, 2021 · 9 comments

Comments

@coderbang1
Copy link


Issue

When i run truffle test following errors occur..
Compiling your contracts...

√ Fetching solc version list from solc-bin. Attempt #1

Compiling .\contracts\Migrations.sol
Compiling .\contracts\SimpleSmartContract.sol
√ Fetching solc version list from solc-bin. Attempt #1
Compilation warnings encountered:

Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: <SPDX-License>" to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.

--> /F/pracdap/contracts/SimpleSmartContract.sol

Artifacts written to C:\Users\HP\AppData\Local\Temp\test--3916-S3hTWsTSHsgH
Compiled successfully using:

  • solc: 0.8.3+commit.8d00100c.Emscripten.clang

Contract: SimpleSmartContract
1) should be deployed
> No events were emitted

0 passing (130ms)
1 failing

  1. Contract: SimpleSmartContract
    should be deployed:
    Error: SimpleSmartContract has not been deployed to detected network (network/artifact mismatch)
    at Object.checkNetworkArtifactMatch (F:\node\node_modules\truffle\build\webpack:\packages\contract\lib\utils\index.js:245:1)
    at Function.deployed (F:\node\node_modules\truffle\build\webpack:\packages\contract\lib\contract\constructorMethods.js:88:1)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at Context. (test\simpleSmartContract.js:5:33)

Steps to Reproduce

Please provide the shortest amount of steps to reproduce your issue.

Expected Behavior

it should run successfully

Actual Results

Error: SimpleSmartContract has not been deployed to detected network (network/artifact mismatch)

Environment

  • Operating System: windows 10

  • Ethereum client:

  • Truffle version (truffle version):Truffle v5.2.6 (core: 5.2.6)

  • node version (node --version):Node v14.16.0

  • npm version (npm --version): 6.14.11

@eggplantzzz
Copy link
Contributor

I believe that warning comes from the Solidity compiler which is telling you to put a license identifier in your contracts. This takes the following form at the top of your Solidity source files:

// SPDX-License-Identifier: MIT

where MIT is the type of license. If you add these that warning should go away. Cheers!

@eggplantzzz
Copy link
Contributor

@coderbang1 oh I seemed to miss the error below the SPDX warning. Are you sure you deployed your contract? Can you share your test?

@coderbang1
Copy link
Author

coderbang1 commented Apr 7, 2021

i will.... can you help me with this? i want to send a certain portion to a specific address with every transaction in Smart Contract

@eggplantzzz
Copy link
Contributor

Sure I will, just share your project with me and I'll take a look for errors. I need to see your code as well as the steps to reproduce the error.

@coderbang1
Copy link
Author

here is the code....


> 1. constructor() public {
> 2.         name = "me";
> 3.         symbol = "me";
> 4.         decimals = 18;
> 5.         _totalSupply = 250000000000000000000000000;
> 6. 
> 7.         balances[msg.sender] = _totalSupply;
> 8.         emit Transfer(address(0), msg.sender, _totalSupply);
> 9.     }
> 10. 
> 11.     function totalSupply() public view returns (uint) {
> 12.         return _totalSupply  - balances[address(0)];
> 13.     }
> 14. 
> 15.     function balanceOf(address tokenOwner) public view returns (uint balance) {
> 16.         return balances[tokenOwner];
> 17.     }
> 18. 
> 19.     function allowance(address tokenOwner, address spender) public view returns (uint remaining) {
> 20.         return allowed[tokenOwner][spender];
> 21.     }
> 22. 
> 23.     function approve(address spender, uint tokens) public returns (bool success) {
> 24.         allowed[msg.sender][spender] = tokens;
> 25.         emit Approval(msg.sender, spender, tokens);
> 26.         return true;
> 27.     }
> 28. 
> 29.     function transfer(address to, uint tokens) public returns (bool success) {
> 30.         balances[msg.sender] = safeSub(balances[msg.sender], tokens);
> 31.         balances[to] = safeAdd(balances[to], tokens);
> 32.         emit Transfer(msg.sender, to, tokens);
> 33.         return true;
> 34.     }
> 35. 
> 36.     function transferFrom(address from, address to, uint tokens) public returns (bool success) {
> 37.         balances[from] = safeSub(balances[from], tokens);
> 38.         allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
> 39.         balances[to] = safeAdd(balances[to], tokens);
> 40.         emit Transfer(from, to, tokens);
> 41.         return true;
> 42.     }``

@eggplantzzz
Copy link
Contributor

Can you provide me with the entire project? I can't troubleshoot deployment issues by just looking at your tests.

@coderbang1
Copy link
Author

this is a smart contract...i want to add functionally like: send a certain portion to a specific address with every transaction in Smart Contract

@eggplantzzz
Copy link
Contributor

You should check out the metacoin box for an example. https://github.com/truffle-box/metacoin-box
You can clone it locally using truffle unbox metacoin in an empty directory.

@cds-amal
Copy link
Member

Hi @coderbang1, we're closing this for issue maintenance. Please comment if you'd like us to reopen. thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants