Client/Test: fix sandbox detection
This commit is contained in:
parent
e264e325f8
commit
122a2421a6
@ -98,6 +98,9 @@ let check_network ctxt =
|
|||||||
Lwt.return_none
|
Lwt.return_none
|
||||||
| Ok versions ->
|
| Ok versions ->
|
||||||
match String.split_on_char '_' (List.hd versions).name with
|
match String.split_on_char '_' (List.hd versions).name with
|
||||||
|
| "SANDBOXED" :: _ ->
|
||||||
|
sandbox () ;
|
||||||
|
Lwt.return_some `Sandbox
|
||||||
| "TEZOS" :: "ZERONET" :: _date :: [] ->
|
| "TEZOS" :: "ZERONET" :: _date :: [] ->
|
||||||
zeronet () ;
|
zeronet () ;
|
||||||
Lwt.return_some `Zeronet
|
Lwt.return_some `Zeronet
|
||||||
@ -107,9 +110,6 @@ let check_network ctxt =
|
|||||||
| "TEZOS" :: "BETANET" :: _date :: [] ->
|
| "TEZOS" :: "BETANET" :: _date :: [] ->
|
||||||
betanet () ;
|
betanet () ;
|
||||||
Lwt.return_some `Betanet
|
Lwt.return_some `Betanet
|
||||||
| "TEZOS" :: _date :: [] ->
|
|
||||||
sandbox () ;
|
|
||||||
Lwt.return_some `Sandbox
|
|
||||||
| _ ->
|
| _ ->
|
||||||
default () ;
|
default () ;
|
||||||
Lwt.return_none
|
Lwt.return_none
|
||||||
|
@ -200,6 +200,7 @@ let init_node ?sandbox ?checkpoint (config : Node_config_file.t) =
|
|||||||
checkpoint ;
|
checkpoint ;
|
||||||
} in
|
} in
|
||||||
Node.create
|
Node.create
|
||||||
|
~sandboxed:(sandbox <> None)
|
||||||
node_config
|
node_config
|
||||||
config.shell.peer_validator_limits
|
config.shell.peer_validator_limits
|
||||||
config.shell.block_validator_limits
|
config.shell.block_validator_limits
|
||||||
|
@ -58,7 +58,7 @@ let init_connection_metadata opt =
|
|||||||
{ disable_mempool = c.P2p.disable_mempool ;
|
{ disable_mempool = c.P2p.disable_mempool ;
|
||||||
private_node = c.P2p.private_mode }
|
private_node = c.P2p.private_mode }
|
||||||
|
|
||||||
let init_p2p p2p_params =
|
let init_p2p ?(sandboxed = false) p2p_params =
|
||||||
match p2p_params with
|
match p2p_params with
|
||||||
| None ->
|
| None ->
|
||||||
let c_meta = init_connection_metadata None in
|
let c_meta = init_connection_metadata None in
|
||||||
@ -70,11 +70,21 @@ let init_p2p p2p_params =
|
|||||||
let conn_metadata_cfg = connection_metadata_cfg c_meta in
|
let conn_metadata_cfg = connection_metadata_cfg c_meta in
|
||||||
lwt_log_notice Tag.DSL.(fun f ->
|
lwt_log_notice Tag.DSL.(fun f ->
|
||||||
f "bootstrapping chain..." -% t event "bootstrapping_chain") >>= fun () ->
|
f "bootstrapping chain..." -% t event "bootstrapping_chain") >>= fun () ->
|
||||||
|
let message_cfg =
|
||||||
|
if sandboxed then
|
||||||
|
{ Distributed_db_message.cfg with
|
||||||
|
versions =
|
||||||
|
List.map
|
||||||
|
(fun v -> { v with P2p_version.name =
|
||||||
|
"SANDBOXED_" ^ v.P2p_version.name })
|
||||||
|
Distributed_db_message.cfg.versions }
|
||||||
|
else
|
||||||
|
Distributed_db_message.cfg in
|
||||||
P2p.create
|
P2p.create
|
||||||
~config ~limits
|
~config ~limits
|
||||||
peer_metadata_cfg
|
peer_metadata_cfg
|
||||||
conn_metadata_cfg
|
conn_metadata_cfg
|
||||||
Distributed_db_message.cfg >>=? fun p2p ->
|
message_cfg >>=? fun p2p ->
|
||||||
Lwt.async (fun () -> P2p.maintain p2p) ;
|
Lwt.async (fun () -> P2p.maintain p2p) ;
|
||||||
return p2p
|
return p2p
|
||||||
|
|
||||||
@ -163,9 +173,11 @@ let may_update_checkpoint chain_state checkpoint =
|
|||||||
Chain.set_head chain_state new_head >>= fun _old_head ->
|
Chain.set_head chain_state new_head >>= fun _old_head ->
|
||||||
State.Chain.set_checkpoint chain_state checkpoint
|
State.Chain.set_checkpoint chain_state checkpoint
|
||||||
|
|
||||||
let create { genesis ; store_root ; context_root ;
|
let create
|
||||||
patch_context ; p2p = p2p_params ;
|
?(sandboxed = false)
|
||||||
test_chain_max_tll = max_child_ttl ; checkpoint }
|
{ genesis ; store_root ; context_root ;
|
||||||
|
patch_context ; p2p = p2p_params ;
|
||||||
|
test_chain_max_tll = max_child_ttl ; checkpoint }
|
||||||
peer_validator_limits
|
peer_validator_limits
|
||||||
block_validator_limits
|
block_validator_limits
|
||||||
prevalidator_limits
|
prevalidator_limits
|
||||||
@ -174,7 +186,7 @@ let create { genesis ; store_root ; context_root ;
|
|||||||
match p2p_params with
|
match p2p_params with
|
||||||
| Some (config, _limits) -> not config.P2p.disable_mempool
|
| Some (config, _limits) -> not config.P2p.disable_mempool
|
||||||
| None -> true in
|
| None -> true in
|
||||||
init_p2p p2p_params >>=? fun p2p ->
|
init_p2p ~sandboxed p2p_params >>=? fun p2p ->
|
||||||
State.read
|
State.read
|
||||||
~store_root ~context_root ?patch_context genesis >>=? fun (state, mainchain_state) ->
|
~store_root ~context_root ?patch_context genesis >>=? fun (state, mainchain_state) ->
|
||||||
may_update_checkpoint mainchain_state checkpoint >>= fun () ->
|
may_update_checkpoint mainchain_state checkpoint >>= fun () ->
|
||||||
|
@ -62,6 +62,7 @@ val default_block_validator_limits: block_validator_limits
|
|||||||
val default_chain_validator_limits: chain_validator_limits
|
val default_chain_validator_limits: chain_validator_limits
|
||||||
|
|
||||||
val create:
|
val create:
|
||||||
|
?sandboxed:bool ->
|
||||||
config ->
|
config ->
|
||||||
peer_validator_limits ->
|
peer_validator_limits ->
|
||||||
block_validator_limits ->
|
block_validator_limits ->
|
||||||
|
Loading…
Reference in New Issue
Block a user