Skip to content

Commit

Permalink
test(rpc): parity tests for Filecoin.F3* RPC methods (#4940)
Browse files Browse the repository at this point in the history
  • Loading branch information
hanabi1224 authored Oct 29, 2024
1 parent 1ba805e commit 2c3ffe5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
2 changes: 0 additions & 2 deletions scripts/tests/api_compare/filter-list
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,3 @@
!Filecoin.EthGetTransactionReceipt
# TODO(elmattic): https://github.com/ChainSafe/forest/issues/4851
!Filecoin.EthGetLogs
# Enable after Lotus image is upgraded to a release in which F3IntitialPowerTable is hard coded.
!Filecoin.F3GetManifest
7 changes: 7 additions & 0 deletions scripts/tests/api_compare/filter-list-offline
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
!Filecoin.NetProtectList
# Most F3 methods are not avaiable on offline Forest RPC server
!Filecoin.F3GetManifest
!Filecoin.F3GetLatestCertificate
!Filecoin.F3ListParticipants
!Filecoin.F3GetProgress
!Filecoin.F3IsRunning
!Filecoin.F3GetCertificate
!Filecoin.F3GetOrRenewParticipationTicket
!Filecoin.F3GetF3PowerTable
# CustomCheckFailed in Forest: https://github.com/ChainSafe/forest/actions/runs/9593268587/job/26453560366
!Filecoin.StateReplay
# CustomCheckFailed in Forest: https://github.com/ChainSafe/forest/actions/runs/9593268587/job/26453560366
Expand Down
22 changes: 20 additions & 2 deletions src/tool/subcommands/api_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1624,15 +1624,32 @@ fn gas_tests_with_tipset(shared_tipset: &Tipset) -> Vec<RpcTest> {
)]
}

fn f3_tests_with_tipset(tipset: &Tipset) -> anyhow::Result<Vec<RpcTest>> {
fn f3_tests() -> anyhow::Result<Vec<RpcTest>> {
Ok(vec![
// using basic because 2 nodes are not garanteed to be at the same head
RpcTest::basic(F3GetECPowerTable::request((None.into(),))?),
RpcTest::identity(F3GetECPowerTable::request((tipset.key().into(),))?),
RpcTest::basic(F3GetLatestCertificate::request(())?),
RpcTest::basic(F3ListParticipants::request(())?),
RpcTest::basic(F3GetProgress::request(())?),
RpcTest::basic(F3GetOrRenewParticipationTicket::request((
Address::new_id(1000),
vec![],
3,
))?),
RpcTest::identity(F3IsRunning::request(())?),
RpcTest::identity(F3GetCertificate::request((0,))?),
RpcTest::identity(F3GetCertificate::request((1000,))?),
RpcTest::identity(F3GetManifest::request(())?),
])
}

fn f3_tests_with_tipset(tipset: &Tipset) -> anyhow::Result<Vec<RpcTest>> {
Ok(vec![
RpcTest::identity(F3GetECPowerTable::request((tipset.key().into(),))?),
RpcTest::identity(F3GetF3PowerTable::request((tipset.key().into(),))?),
])
}

// Extract tests that use chain-specific data such as block CIDs or message
// CIDs. Right now, only the last `n_tipsets` tipsets are used.
fn snapshot_tests(
Expand Down Expand Up @@ -1733,6 +1750,7 @@ fn create_tests(
tests.extend(wallet_tests(worker_address));
tests.extend(eth_tests());
tests.extend(state_tests());
tests.extend(f3_tests()?);
if !snapshot_files.is_empty() {
let store = Arc::new(ManyCar::try_from(snapshot_files)?);
tests.extend(snapshot_tests(
Expand Down

0 comments on commit 2c3ffe5

Please sign in to comment.