Skip to content

Commit

Permalink
follow review opinion
Browse files Browse the repository at this point in the history
  • Loading branch information
Eason committed Aug 11, 2023
1 parent d5a0fbe commit 4fbfc16
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions protocol/src/traits/interoperation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ pub const SIGNATURE_HASH_CELL_OCCUPIED_CAPACITY: u64 = signature_hash_cell_bytes
/// args: 0x
/// hash_type: data
/// data: signature hash(32 bytes)
/// capacity: 0x1ad274800
/// capacity: 1b31d2900
/// ```
/// So the occupied bytes is 32 + 32 + 8 = 72 bytes.
/// So the occupied bytes is 32 + 32 + 1 + 8 = 73 bytes.
const fn signature_hash_cell_bytes() -> u64 {
32 + 32 + 8
32 + 32 + 1 + 8
}

pub trait Interoperation: Sync + Send {
Expand Down Expand Up @@ -111,3 +111,20 @@ pub trait Interoperation: Sync + Send {
.build()
}
}

#[cfg(test)]
mod tests {
use super::*;
use ckb_types::core::Capacity;

#[test]
fn test_const_signature_hash_cell_bytes() {
let data_capacity = Capacity::bytes(32).unwrap();
let actual = packed::CellOutputBuilder::default()
.build()
.occupied_capacity(data_capacity)
.unwrap()
.as_u64();
assert_eq!(SIGNATURE_HASH_CELL_OCCUPIED_CAPACITY, actual);
}
}

0 comments on commit 4fbfc16

Please sign in to comment.