Skip to content

Commit

Permalink
Tests: pass Core to test-contract's constructor so to test native tra…
Browse files Browse the repository at this point in the history
…nsfer before contract deployment
  • Loading branch information
giladHaimov committed Jun 18, 2024
1 parent 7d17d3d commit 7ea3b5a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,16 @@ npx hardhat run --network privatenet hardhat/lfmDeployTestContract.js
*/

async function main() {
const RECEIVER = "0x1637b6776c408929580ad68b68ef0c80c6398bab";
const CONTRACT_NAME = "LfmTestContract";

const [signer] = await ethers.getSigners();
console.log("Deploying contract with the account: ", signer.address);
const _value = ethers.parseUnits(String(1e8), 'wei'); // 0.1 gwei

const LfmTestContract = await ethers.getContractFactory(CONTRACT_NAME);
contract = await LfmTestContract.deploy();
// pass eth to CTOR so to invoke transfer before contract is deployed resulting in code-size==0
const contract = await LfmTestContract.deploy(RECEIVER, { from: signer.address, value: _value });
const contractAddr = await contract.getAddress();
console.log("\ncontract address (to be copied into lfmExecuteTestContract.js): ", contractAddr);
}
Expand Down
6 changes: 6 additions & 0 deletions external-tests/lfm/LFMTestContract/src/LfmTestContract.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ contract LfmTestContract {

uint public val;

constructor(address to) payable {
if (msg.value > 0) {
transferCoreTo(to, msg.value);
}
}

fallback() external payable {} // allow receival of funds

function injectSomeCash() external payable {}
Expand Down

0 comments on commit 7ea3b5a

Please sign in to comment.