-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7aebf75
commit c6b71f6
Showing
7 changed files
with
72 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
x/evm/embeds/artifacts/contracts/TestRandom.sol/TestRandom.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"_format": "hh-sol-artifact-1", | ||
"contractName": "TestRandom", | ||
"sourceName": "contracts/TestRandom.sol", | ||
"abi": [ | ||
{ | ||
"inputs": [], | ||
"name": "getRandom", | ||
"outputs": [ | ||
{ | ||
"internalType": "uint256", | ||
"name": "", | ||
"type": "uint256" | ||
} | ||
], | ||
"stateMutability": "view", | ||
"type": "function" | ||
} | ||
], | ||
"bytecode": "0x608060405234801561001057600080fd5b5060b58061001f6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063aacc5a1714602d575b600080fd5b60336047565b604051603e91906066565b60405180910390f35b600044905090565b6000819050919050565b606081604f565b82525050565b6000602082019050607960008301846059565b9291505056fea264697066735822122021d2de67a73b1cbeefb199f56299f80c5f7aeb23a677b105ef78f6880f75491464736f6c63430008180033", | ||
"deployedBytecode": "0x6080604052348015600f57600080fd5b506004361060285760003560e01c8063aacc5a1714602d575b600080fd5b60336047565b604051603e91906066565b60405180910390f35b600044905090565b6000819050919050565b606081604f565b82525050565b6000602082019050607960008301846059565b9291505056fea264697066735822122021d2de67a73b1cbeefb199f56299f80c5f7aeb23a677b105ef78f6880f75491464736f6c63430008180033", | ||
"linkReferences": {}, | ||
"deployedLinkReferences": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// contracts/TestERC20.sol | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.24; | ||
|
||
contract TestRandom { | ||
|
||
function getRandom() public view returns (uint256) { | ||
return block.prevrandao; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (c) 2023-2024 Nibi, Inc. | ||
package keeper_test | ||
|
||
import ( | ||
"github.com/NibiruChain/nibiru/v2/x/evm/embeds" | ||
"github.com/NibiruChain/nibiru/v2/x/evm/evmtest" | ||
) | ||
|
||
// TestRandom tests the random value generation within the EVM. | ||
func (s *Suite) TestRandom() { | ||
deps := evmtest.NewTestDeps() | ||
deployResp, err := evmtest.DeployContract(&deps, embeds.SmartContract_TestRandom) | ||
s.Require().NoError(err) | ||
randomContractAddr := deployResp.ContractAddr | ||
|
||
// highjacked LoadERC20BigInt method as it perfectly fits the need of this test | ||
resp, err := deps.EvmKeeper.LoadERC20BigInt( | ||
deps.Ctx, embeds.SmartContract_TestRandom.ABI, randomContractAddr, "getRandom", | ||
) | ||
s.Require().NoError(err) | ||
s.Require().Greater(resp.Int64(), int64(0)) | ||
} |