message: chore: refactor TemplateSizeLimit integration test
diff: @@ -11,7 +11,9 @@ impl Spec for TemplateSizeLimit {
  let node = &net.nodes[0];
  info!("Generate 1 block");
  - node.generate_block();
  + let blank_block = node.new_block(None, None, None);
  + node.submit_block(&blank_block.data());
  + let blank_block_size = blank_block.serialized_size();
  info!("Generate 6 txs");
  let mut txs_hash = Vec::new();
  @@ -19,6 +21,12 @@ impl Spec for TemplateSizeLimit {
  let cellbase = &block.transactions()[0];
  let capacity = cellbase.outputs().get(0).unwrap().capacity().unpack();
  let tx = node.new_transaction_with_since_capacity(cellbase.hash(), 0, capacity);
  + let tx_size = tx.serialized_size();
  + info!(
  + "blank_block_size: {}, tx_size: {}",
  + blank_block_size, tx_size
  + );
  +
  let mut hash = node.rpc_client().send_transaction(tx.data().into());
  txs_hash.push(hash.clone());
  @@ -28,14 +36,19 @@ impl Spec for TemplateSizeLimit {
  txs_hash.push(hash.clone());
  });
  - let _ = node.generate_block();
  - let _ = node.generate_block(); // skip
  + // skip proposal window
  + node.generate_block();
  + node.generate_block();
  let new_block = node.new_block(None, None, None);
  - assert_eq!(new_block.serialized_size(), 550 + 242 * 6);
  + assert_eq!(new_block.serialized_size(), blank_block_size + tx_size * 6);
  + // 6 txs + 1 cellbase tx
  assert_eq!(new_block.transactions().len(), 7);
  - let new_block = node.new_block(Some(1000), None, None);
  - assert_eq!(new_block.transactions().len(), 2);
  + for bytes_limit in (1000..=2000).step_by(100) {
  + let new_block = node.new_block(Some(bytes_limit), None, None);
  + let tx_num = ((bytes_limit as usize) - blank_block_size) / tx_size;
  + assert_eq!(new_block.transactions().len(), tx_num + 1);
  + }
  }
  }
  