1 个不稳定版本
0.0.1 | 2020年4月25日 |
---|
#13 在 #ledger-hardware
8KB
118 行
transport-mock
是 ledger_hw_transport::Transport
特性的模拟实现。
示例
#[async_test]
async fn test_get_wallet_public_key() {
let mock = TransportReplayer::new(
RecordStore::from_str(
"=> e040000011048000002c800000008000000000000000
<= 410486b865b52b753d0a84d09bc20063fab5d8453ec33c215d4019a5801c9c6438b917770b2782e29a9ecc6edb67cd1f0fbf05ec4c1236884b6d686d6be3b1588abb2231334b453654666641724c683466564d36756f517a7673597135767765744a63564dbce80dd580792cd18af542790e56aa813178dc28644bb5f03dbd44c85f2d2e7a9000
",
).unwrap()
);
let path = DerivationPath::from_str("m/44'/0'/0'/0").unwrap();
let (key, address, chaincode) = get_wallet_public_key(&mock, &path, false, AddressFormat::Legacy).await.unwrap();
assert_eq!(Address::from_str("13KE6TffArLh4fVM6uoQzvsYq5vwetJcVM").unwrap(), address);
assert_eq!(PublicKey::from_str("0486b865b52b753d0a84d09bc20063fab5d8453ec33c215d4019a5801c9c6438b917770b2782e29a9ecc6edb67cd1f0fbf05ec4c1236884b6d686d6be3b1588abb").unwrap(), key);
let chaincode_bytes = hex::decode("bce80dd580792cd18af542790e56aa813178dc28644bb5f03dbd44c85f2d2e7a").unwrap();
assert_eq!(ChainCode::from(&chaincode_bytes[..]), chaincode);
}
```
依赖项
~2.5–4MB
~71K SLoC