Skip to content

Commit

Permalink
fix forest-cli chain block output (#4062)
Browse files Browse the repository at this point in the history
  • Loading branch information
LesnyRumcajs authored Mar 15, 2024
1 parent ce9dcae commit 59ff9a4
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 2 deletions.
7 changes: 6 additions & 1 deletion scripts/tests/calibnet_offline_rpc_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ done
for port in "${PORTS[@]}"; do
# Assert an old block is present, given that the old snapshot is used.
# https://calibration.filfox.info/en/block/bafy2bzacecpjvcld56dazyukvj35uzwvlh3tb4ga2lvbgbiua3mgbqaz45hbm
FULLNODE_API_INFO="/ip4/127.0.0.1/tcp/$port/http" forest-cli chain block -c bafy2bzacecpjvcld56dazyukvj35uzwvlh3tb4ga2lvbgbiua3mgbqaz45hbm
temp_dir=$(mktemp -d)
FULLNODE_API_INFO="/ip4/127.0.0.1/tcp/$port/http" forest-cli chain block -c bafy2bzacecpjvcld56dazyukvj35uzwvlh3tb4ga2lvbgbiua3mgbqaz45hbm | jq . > "$temp_dir/block.json"

# assert block is as expected
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
diff "$parent_path/test_data/calibnet_block_3000.json" "$temp_dir/block.json"
done

# Compare the http endpoints
Expand Down
55 changes: 55 additions & 0 deletions scripts/tests/test_data/calibnet_block_3000.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"Miner": "t01001",
"Ticket": {
"VRFProof": "tqvA2eKxv41idBKYyfn5s5NILa0ZbDCm0I966PxITW9v41zjaK+WBTlKt01HyJA6C547A1QnNmfl44RmU/ZzC6p7TJJeiB1ZSgbTu6oUmWoHokxN5w4wPJcqslfNCjcy"
},
"ElectionProof": {
"VRFProof": "lgQnCwE/R199jfPpK+/CXQyZwyyldgm9zATRG3KdD765ObLZsYLJEzJP7WspEhVxABhKbWqtR6iWuMqCfFYET+rQjv6q/7/HOnXxGm4NA+Vk/D6Py6B7dFpDJ0ynE1xA",
"WinCount": 1
},
"BeaconEntries": [
{
"Round": 2399511,
"Data": "gnEZiH4il5dkAhPmjF9s5xNYnFuLHnhSD2h+VnAh6j2PmNxZQKYqglWxAjr1TrUBEWvXCHqJX8Mlq0cHTQlGSMsyuvDiWVr7QBS7ianOvs5iZXbkq1MwSdySq6eBTkuo"
}
],
"WinPoStProof": [
{
"PoStProof": 3,
"ProofBytes": "qZnqYHOeLxuKrw+zsgVq7RBoVZXuuLg/P4k2yRtGcCG5QPA7qq36WfCb8t9if9AkoXMCjRI/mV9GQyqDRyxn4ZCuA6Mco9js5Jh9+ZXgXIpD5aqk/DFzJAdAspI5MYT8Duk9xmKeN9w5j8RhkwqCgMhUruuvPBPbnGxOUKGMDMt6VZYBEj0BcmkHy1Tm7wG4rSv2eGRcCn9xNtgrJaJii8O4BO1GtbXAkvxLBgAJQqHUQ4Ci06bjC28hFa3DUx1Z"
}
],
"Parents": [
{
"/": "bafy2bzaceboy6rk5lzoxhk2q2vmzq2yjmgtdzsaax4tret2iymumjcp4ohfjy"
},
{
"/": "bafy2bzaceaq5l57fo35ejowp6lxk3v3klrol35idwwon4ipqavcymf5vuqhyy"
},
{
"/": "bafy2bzacecf6vunv62ofnf2pms4ro7evx5vtzcpmyr5vqs2gixzerc4svtyu2"
}
],
"ParentWeight": "56159550",
"Height": 3000,
"ParentStateRoot": {
"/": "bafy2bzacebjbt5nwgof7jaqwngr3yxmisdofqkuafsznxbau66wahznafipwm"
},
"ParentMessageReceipts": {
"/": "bafy2bzacedswlcz5ddgqnyo3sak3jmhmkxashisnlpq6ujgyhe4mlobzpnhs6"
},
"Messages": {
"/": "bafy2bzacecmda75ovposbdateg7eyhwij65zklgyijgcjwynlklmqazpwlhba"
},
"BLSAggregate": {
"Type": 2,
"Data": "wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
},
"Timestamp": 1667416380,
"BlockSig": {
"Type": 2,
"Data": "uJABIrNb5zlpbDCFpEW4nV0l77pYG/v2mC+XZYlx81JHC+81si+WjTXdSHU4fDRcCCfcBP798MvIfj6Faky2mCS1C6CHgEvpZCHQ1eXVBDxTGFHxu1ZEXiT98bsflEzl"
},
"ForkSignaling": 0,
"ParentBaseFee": "100"
}
4 changes: 3 additions & 1 deletion src/cli/subcommands/chain_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ pub enum ChainCommands {
impl ChainCommands {
pub async fn run(self, api: ApiInfo) -> anyhow::Result<()> {
match self {
Self::Block { cid } => print_pretty_json(api.chain_get_block(cid).await?),
Self::Block { cid } => {
print_pretty_json(api.chain_get_block(cid).await?.into_lotus_json())
}
Self::Genesis => print_pretty_json(LotusJson(api.chain_get_genesis().await?)),
Self::Head => print_rpc_res_cids(api.chain_head().await?),
Self::Message { cid } => {
Expand Down

0 comments on commit 59ff9a4

Please sign in to comment.