Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/tests/api_compare/.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Note: this should be a `fat` image so that it contains the pre-downloaded filecoin proof parameters
FOREST_IMAGE=ghcr.io/chainsafe/forest:edge-fat
LOTUS_IMAGE=filecoin/lotus-all-in-one:82ce112b1-calibnet
LOTUS_IMAGE=filecoin/lotus-all-in-one:72ac4c059-calibnet
FIL_PROOFS_PARAMETER_CACHE=/var/tmp/filecoin-proof-parameters
LOTUS_RPC_PORT=1234
LOTUS_VIA_GATEWAY_RPC_PORT=4568
Expand Down
53 changes: 37 additions & 16 deletions src/tool/subcommands/api_cmd/api_compare_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ const COLLECTION_SAMPLE_SIZE: usize = 5;
const SAFE_EPOCH_DELAY_FOR_TESTING: i64 = 20; // `SAFE_HEIGHT_DISTANCE`(200) is too large for testing
const MESSAGE_LOOKBACK_LIMIT: i64 = 2000;

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
enum ServerMode {
Online,
Offline,
}

/// This address has been funded by the calibnet faucet and the private keys
/// has been discarded. It should always have a non-zero balance.
static KNOWN_CALIBNET_ADDRESS: LazyLock<Address> = LazyLock::new(|| {
Expand Down Expand Up @@ -482,18 +488,20 @@ fn common_tests() -> Vec<RpcTest> {
]
}

fn chain_tests(offline: bool) -> Vec<RpcTest> {
fn chain_tests(server_mode: ServerMode) -> Vec<RpcTest> {
vec![
RpcTest::identity(ChainGetGenesis::request(()).unwrap()),
if offline {
RpcTest::basic(ChainHead::request(()).unwrap())
} else {
RpcTest::identity(ChainHead::request(()).unwrap())
match server_mode {
ServerMode::Offline => RpcTest::basic(ChainHead::request(()).unwrap()),
ServerMode::Online => RpcTest::identity(ChainHead::request(()).unwrap()),
},
if offline {
RpcTest::basic(ChainGetTipSetFinalityStatus::request(()).unwrap())
} else {
RpcTest::identity(ChainGetTipSetFinalityStatus::request(()).unwrap())
match server_mode {
ServerMode::Offline => {
RpcTest::basic(ChainGetTipSetFinalityStatus::request(()).unwrap())
}
ServerMode::Online => {
RpcTest::identity(ChainGetTipSetFinalityStatus::request(()).unwrap())
}
},
RpcTest::basic(ChainGetFinalizedTipset::request(()).unwrap()),
]
Expand Down Expand Up @@ -1384,17 +1392,21 @@ fn wallet_tests(worker_address: Option<Address>) -> Vec<RpcTest> {
tests
}

fn eth_tests() -> anyhow::Result<Vec<RpcTest>> {
fn eth_tests(server_mode: ServerMode) -> anyhow::Result<Vec<RpcTest>> {
let mut tests = vec![];
for use_alias in [false, true] {
tests.push(RpcTest::identity(EthAccounts::request_with_alias(
(),
use_alias,
)?));
tests.push(RpcTest::basic(EthBlockNumber::request_with_alias(
(),
use_alias,
)?));
tests.push(match server_mode {
ServerMode::Online => {
RpcTest::identity(EthBlockNumber::request_with_alias((), use_alias)?)
}
ServerMode::Offline => {
RpcTest::basic(EthBlockNumber::request_with_alias((), use_alias)?)
}
});
tests.push(RpcTest::identity(EthChainId::request_with_alias(
(),
use_alias,
Expand Down Expand Up @@ -1434,6 +1446,10 @@ fn eth_tests() -> anyhow::Result<Vec<RpcTest>> {
(),
use_alias,
)?));
tests.push(match server_mode {
ServerMode::Online => RpcTest::identity(EthBaseFee::request_with_alias((), use_alias)?),
ServerMode::Offline => RpcTest::basic(EthBaseFee::request_with_alias((), use_alias)?),
});

let cases = [
(
Expand Down Expand Up @@ -2520,15 +2536,20 @@ pub(super) async fn create_tests(
snapshot_files,
}: CreateTestsArgs,
) -> anyhow::Result<Vec<RpcTest>> {
let server_mode = if offline {
ServerMode::Offline
} else {
ServerMode::Online
};
let mut tests = vec![];
tests.extend(auth_tests()?);
tests.extend(common_tests());
tests.extend(chain_tests(offline));
tests.extend(chain_tests(server_mode));
tests.extend(mpool_tests());
tests.extend(net_tests());
tests.extend(node_tests());
tests.extend(wallet_tests(worker_address));
tests.extend(eth_tests()?);
tests.extend(eth_tests(server_mode)?);
tests.extend(f3_tests()?);
if !snapshot_files.is_empty() {
let store = Arc::new(ManyCar::try_from(snapshot_files.clone())?);
Expand Down
1 change: 1 addition & 0 deletions src/tool/subcommands/api_cmd/test_snapshots.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ filecoin_eam_statedecodeparams_1756139121347364.rpcsnap.json.zst
filecoin_ethaccount_statedecodeparams_1756186350854913.rpcsnap.json.zst
filecoin_ethaccounts_1737446676689764.rpcsnap.json.zst
filecoin_ethaddresstofilecoinaddress_1740132538465536.rpcsnap.json.zst
filecoin_ethbasefee_1778755118342258.rpcsnap.json.zst
filecoin_ethblocknumber_1741272348346171.rpcsnap.json.zst
filecoin_ethcall_1744204533050503.rpcsnap.json.zst
filecoin_ethcall_1744204533058637.rpcsnap.json.zst
Expand Down
1 change: 0 additions & 1 deletion src/tool/subcommands/api_cmd/test_snapshots_ignored.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ Filecoin.ChainExport
Filecoin.ChainGetEvents
Filecoin.ChainGetFinalizedTipset
Filecoin.ChainSetHead
Filecoin.EthBaseFee
Filecoin.EthEstimateGas
Filecoin.EthGetFilterChanges
Filecoin.EthGetFilterLogs
Expand Down
Loading