Use of natural chips as a charge for units tests for local units CCIP
When Ethereum Testnet or Mainnet is a decentralized application (programs), it is very important to have a reliable and effective way to manage operations commissions. In this article, we will examine how to use local tokens such as ETH as a paid access key for a cross -interaction protocol (CCIP) units tests.
CCIP device set up with Connection Toks
Using links such as Ethereum Testnet or Mainnet, we can use CCIPS local tokens to simplify our test process. Here is a step by step guide:
- Setting a test portfolio : Create a new Ethereum testnet test portfolio (eg alchemy test) and set it as a default wallet.
2.
- Define the test kit
: Create a new test file (eg
et.t.js
) and import ‘CCIP-test. Define a simple test case that uses a link as an access key:
`Javascript
CONST {CCIP} = Claim (‘/ CCIP ‘);
CONST {alchemyestnet} = requirement (‘alchemy-testsnet’);
Describe (‘ethfee’, () => {
This ( » he should pay eth for each operation ‘, Asinn () => {
CONST Contract = New CCIP ();
CONST TXID = Waiting Agreement.
From: ‘0x …’, // The sender’s address
A: ‘0x …’,
Value: 100,
Price, which: 1e8,
});
CONST score = wait for txid.At 10 (10);
Wait (result.status) .tobe (‘okay’);
Wait (result.txhash) .Not.tobeandefined ();
Wait (result.value) .toblessthan (txid.gasprice * 10); // eth
});
});
`
4.
- Check the results
: Notice that the test passes without paying any ETH for each operation.
Use of natural chips as a charge in unit tests
Now we modify our test kit to use ETH as a paid access key:
- Change connection ETH : Update the AC link to the test file to specify the ETH account Testnet Ethereum (eg Alchemia Test).
- Edit test case : Update the test case to use ETH as an input to the commissions:
Javascript
CONST {CCIP} = Claim (‘/ CCIP ‘);
CONST {alchemyestnet} = requirement (‘alchemy-testsnet’);
Describe (‘ethfee’, () => {
This ( » he should pay eth for each operation ‘, Asinn () => {
CONST Contract = New CCIP ();
CONST TXID = Waiting Agreement.
From: ‘0x …’, // The sender’s address
A: ‘0x …’,
Value: 100,
Price, which: 1e8,
Commission: 0.01,
});
CONST score = wait for txid.At 10 (10);
Wait (result.status) .tobe (‘okay’);
Wait (result.txhash) .Not.tobeandefined ();
Wait (result.value) .toblessthan (txid.gasprice * 100); // eth
});
});
``
- Make a test : Complete and perform a contract with Ethereum testnet (such as alchemy test) using « triumph compilies » is a torch running.
- Check the results : Please note that the test passes without paying any ETH for each operation.
Conclusion
Using local chips such as ETH as a paid access key, we can simplify our units of CCIP Ethereum Testnet or Mainnet. Not only does this approach reduce time, it is also a more effective way to manage operations commissions, facilitate development and test decentralized programs.