Error in writing Test #2487
Unanswered
MostPow3rful
asked this question in
Q&A
Replies: 3 comments 24 replies
-
Please show all the stack trace of your test, |
Beta Was this translation helpful? Give feedback.
3 replies
-
Can you figure out why you deployed the following twice in your test process |
Beta Was this translation helpful? Give feedback.
4 replies
-
Try with the below as your // SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
import {Script} from "forge-std/Script.sol";
import {VRFCoordinatorV2_5Mock} from "@chainlink/contracts/src/v0.8/vrf/mocks/VRFCoordinatorV2_5Mock.sol";
import {LinkToken} from "test/mocks/LinkToken.sol";
abstract contract ConfigDetails {
int256 public constant VRF_MOCK_WEI_PER_UINT_LINK = 4 * (10 ** 15);
uint96 public constant VRF_MOCK_GAS_PRICE_LINK = 10 ** 9;
uint96 public constant VRF_MOCK_BASE_FEE = 0.25 ether;
uint256 public constant SEPOLIA_CHAIN_ID = 11155111;
uint256 public constant ANVIL_CHAIN_ID = 31337;
}
contract Config is Script, ConfigDetails {
error Config__NotSupportedChain(uint256 chainid);
struct NetworkConfig {
uint256 entranceFee;
uint256 duration;
uint256 subscriptionId;
uint32 callbackGasLimit;
bytes32 keyHash;
address vrfCoordinator;
address link;
}
NetworkConfig public thisNetworkConfig;
mapping(uint256 chainId => NetworkConfig config) networkConfigs;
constructor() {
networkConfigs[SEPOLIA_CHAIN_ID] = getSepoliaConfig();
networkConfigs[ANVIL_CHAIN_ID] = getAnvilConfig();
}
function getConfig() public view returns (NetworkConfig memory) {
if (networkConfigs[block.chainid].vrfCoordinator != address(0)) {
return networkConfigs[block.chainid];
} else {
revert Config__NotSupportedChain(block.chainid);
}
}
function getSepoliaConfig() public pure returns (NetworkConfig memory) {
return NetworkConfig({
keyHash: 0x787d74caea10b2b357790d5b5247c2f63d1d91572a9846f780606e4d953677ae,
vrfCoordinator: 0x9DdfaCa8183c41ad55329BdeeD9F6A8d53168B1B,
link: 0x779877A7B0D9E8603169DdbD7836e478b4624789,
callbackGasLimit: 500000,
entranceFee: 0.01 ether,
subscriptionId: 10667821297455373145096742310695665753913332581852544371547977367707552846047, // must be 0
duration: 30
});
}
function getAnvilConfig() public returns (NetworkConfig memory) {
if (thisNetworkConfig.vrfCoordinator != address(0)) {
return thisNetworkConfig;
}
vm.startBroadcast();
VRFCoordinatorV2_5Mock vrfCoordinatorMock =
new VRFCoordinatorV2_5Mock(VRF_MOCK_BASE_FEE, VRF_MOCK_GAS_PRICE_LINK, VRF_MOCK_WEI_PER_UINT_LINK);
LinkToken linkTokenMock = new LinkToken();
vm.stopBroadcast();
NetworkConfig thisNetworkConfig = NetworkConfig({
keyHash: 0x787d74caea10b2b357790d5b5247c2f63d1d91572a9846f780606e4d953677ae,
vrfCoordinator: address(vrfCoordinatorMock),
link: address(linkTokenMock),
callbackGasLimit: 500000,
entranceFee: 0.01 ether,
subscriptionId: 0,
duration: 30
});
networkConfigs[ANVIL_CHAIN_ID] = thisNetworkConfig;
return thisNetworkConfig;
}
} |
Beta Was this translation helpful? Give feedback.
17 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
GM
Source Code
Error
i did the same steps which patrick did. but i don't know how he succesed and i failed
Beta Was this translation helpful? Give feedback.
All reactions