@@ -9,7 +9,7 @@ use std::rc::Rc;
9
9
use anyhow:: anyhow;
10
10
use cid:: multihash:: { Code , Multihash as OtherMultihash } ;
11
11
use cid:: Cid ;
12
- use fvm_ipld_blockstore:: MemoryBlockstore ;
12
+ use fvm_ipld_blockstore:: { Blockstore , MemoryBlockstore } ;
13
13
use fvm_ipld_encoding:: de:: DeserializeOwned ;
14
14
use fvm_ipld_encoding:: { Cbor , CborStore , RawBytes } ;
15
15
use fvm_shared:: address:: Payload ;
@@ -103,7 +103,7 @@ pub fn make_builtin(bz: &[u8]) -> Cid {
103
103
Cid :: new_v1 ( IPLD_RAW , OtherMultihash :: wrap ( 0 , bz) . expect ( "name too long" ) )
104
104
}
105
105
106
- pub struct MockRuntime {
106
+ pub struct MockRuntime < BS = MemoryBlockstore > {
107
107
pub epoch : ChainEpoch ,
108
108
pub miner : Address ,
109
109
pub base_fee : TokenAmount ,
@@ -124,7 +124,7 @@ pub struct MockRuntime {
124
124
125
125
// VM Impl
126
126
pub in_call : bool ,
127
- pub store : Rc < MemoryBlockstore > ,
127
+ pub store : Rc < BS > ,
128
128
pub in_transaction : bool ,
129
129
130
130
// Expectations
@@ -249,6 +249,12 @@ impl Expectations {
249
249
250
250
impl Default for MockRuntime {
251
251
fn default ( ) -> Self {
252
+ Self :: new ( Default :: default ( ) )
253
+ }
254
+ }
255
+
256
+ impl < BS > MockRuntime < BS > {
257
+ pub fn new ( store : BS ) -> Self {
252
258
Self {
253
259
epoch : Default :: default ( ) ,
254
260
miner : Address :: new_id ( 0 ) ,
@@ -265,7 +271,7 @@ impl Default for MockRuntime {
265
271
state : Default :: default ( ) ,
266
272
balance : Default :: default ( ) ,
267
273
in_call : Default :: default ( ) ,
268
- store : Default :: default ( ) ,
274
+ store : Rc :: new ( store ) ,
269
275
in_transaction : Default :: default ( ) ,
270
276
expectations : Default :: default ( ) ,
271
277
policy : Default :: default ( ) ,
@@ -391,7 +397,7 @@ pub fn expect_abort<T: fmt::Debug>(exit_code: ExitCode, res: Result<T, ActorErro
391
397
expect_abort_contains_message ( exit_code, "" , res) ;
392
398
}
393
399
394
- impl MockRuntime {
400
+ impl < BS : Blockstore > MockRuntime < BS > {
395
401
///// Runtime access for tests /////
396
402
397
403
pub fn get_state < T : Cbor > ( & self ) -> T {
@@ -655,7 +661,7 @@ impl MockRuntime {
655
661
}
656
662
}
657
663
658
- impl MessageInfo for MockRuntime {
664
+ impl < BS > MessageInfo for MockRuntime < BS > {
659
665
fn caller ( & self ) -> Address {
660
666
self . caller
661
667
}
@@ -667,7 +673,7 @@ impl MessageInfo for MockRuntime {
667
673
}
668
674
}
669
675
670
- impl Runtime < Rc < MemoryBlockstore > > for MockRuntime {
676
+ impl < BS : Blockstore > Runtime < Rc < BS > > for MockRuntime < BS > {
671
677
fn network_version ( & self ) -> NetworkVersion {
672
678
self . network_version
673
679
}
@@ -880,7 +886,7 @@ impl Runtime<Rc<MemoryBlockstore>> for MockRuntime {
880
886
ret
881
887
}
882
888
883
- fn store ( & self ) -> & Rc < MemoryBlockstore > {
889
+ fn store ( & self ) -> & Rc < BS > {
884
890
& self . store
885
891
}
886
892
@@ -1010,7 +1016,7 @@ impl Runtime<Rc<MemoryBlockstore>> for MockRuntime {
1010
1016
}
1011
1017
}
1012
1018
1013
- impl Primitives for MockRuntime {
1019
+ impl < BS > Primitives for MockRuntime < BS > {
1014
1020
fn verify_signature (
1015
1021
& self ,
1016
1022
signature : & Signature ,
@@ -1085,7 +1091,7 @@ impl Primitives for MockRuntime {
1085
1091
}
1086
1092
}
1087
1093
1088
- impl Verifier for MockRuntime {
1094
+ impl < BS > Verifier for MockRuntime < BS > {
1089
1095
fn verify_seal ( & self , seal : & SealVerifyInfo ) -> anyhow:: Result < ( ) > {
1090
1096
let exp = self
1091
1097
. expectations
@@ -1213,7 +1219,7 @@ impl Verifier for MockRuntime {
1213
1219
}
1214
1220
}
1215
1221
1216
- impl RuntimePolicy for MockRuntime {
1222
+ impl < BS > RuntimePolicy for MockRuntime < BS > {
1217
1223
fn policy ( & self ) -> & Policy {
1218
1224
& self . policy
1219
1225
}
0 commit comments