Skip to content

Commit 7ce72fb

Browse files
authored
feat!: default to PocketIC (#4130)
1 parent 903f21d commit 7ce72fb

File tree

14 files changed

+108
-103
lines changed

14 files changed

+108
-103
lines changed

.github/workflows/e2e.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ jobs:
160160
echo "archive=$(pwd)/e2e/archive" >> "$GITHUB_ENV"
161161
echo "assets=$(pwd)/e2e/assets" >> "$GITHUB_ENV"
162162
echo "utils=$(pwd)/e2e/utils" >> "$GITHUB_ENV"
163-
if [ "${{ matrix.backend == 'pocketic' || '' }}" ]; then
164-
echo "USE_POCKETIC=1" >> "$GITHUB_ENV"
163+
if [ "${{ matrix.backend == 'replica' || '' }}" ]; then
164+
echo "USE_REPLICA=1" >> "$GITHUB_ENV"
165165
fi
166166
export
167167
- name: Download bats-support as a git submodule

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
# UNRELEASED
44

5+
### feat!: `dfx start` uses `--pocketic` by default
6+
7+
As [announced](https://forum.dfinity.org/t/dfx-replacing-the-local-replica-with-pocketic/40167) `dfx start` now runs PocketIC by default.
8+
Running a local replica is still possible with `--replica`, but this option will be removed in the near future.
9+
510
# 0.25.1
611

712
### feat: `skip_cargo_audit` flag in dfx.json to skip `cargo audit` build step

CONTRIBUTING.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,19 @@ If there is already an entry in the 'Unreleased' section, change it; if not, add
5959

6060
#### Running End-to-End Tests
6161

62+
This runs the end-to-end tests against the
63+
[PocketIC emulator](https://github.com/dfinity/pocketic).
64+
6265
``` bash
6366
sdk $ bats e2e/tests-dfx/*.bash
6467
sdk $ bats e2e/tests-replica/*.bash
6568
```
6669

67-
#### Running End-to-End Tests Against Reference IC
68-
69-
This runs the end-to-end tests against the
70-
[PocketIC emulator](https://github.com/dfinity/pocketic).
70+
#### Running End-to-End Tests Against Local Replica
7171

7272
``` bash
73-
sdk $ USE_POCKETIC=1 bats e2e/tests-dfx/*.bash
74-
sdk $ USE_POCKETIC=1 bats e2e/tests-replica/*.bash
73+
sdk $ USE_REPLICA=1 bats e2e/tests-dfx/*.bash
74+
sdk $ USE_REPLICA=1 bats e2e/tests-replica/*.bash
7575
```
7676

7777
## Conventional Commits

e2e/assets/expect_scripts/ctrl_c_right_after_dfx_start.exp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ set timeout 330
55

66
spawn dfx cache install
77
expect "Installed dfx"
8-
if [info exists env(USE_POCKETIC)] {
9-
spawn dfx start --pocketic --clean
8+
if [info exists env(USE_REPLICA)] {
9+
spawn dfx start --replica --clean
1010
} else {
1111
spawn dfx start --clean
1212
}

e2e/tests-dfx/bitcoin.bash

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ set_local_network_bitcoin_enabled() {
3737
}
3838

3939
@test "dfx restarts replica when ic-btc-adapter restarts" {
40-
[[ "$USE_POCKETIC" ]] && skip "skipped for pocketic: bitcoin adapter is a replica implementation detail"
40+
[[ ! "$USE_REPLICA" ]] && skip "skipped for pocketic: bitcoin adapter is a replica implementation detail"
4141
dfx_new_assets hello
4242
dfx_start --enable-bitcoin
4343

@@ -87,15 +87,15 @@ set_local_network_bitcoin_enabled() {
8787
}
8888

8989
@test "dfx start --bitcoin-node <node> implies --enable-bitcoin" {
90-
[[ "$USE_POCKETIC" ]] && skip "skipped for pocketic: bitcoin adapter is a replica implementation detail"
90+
[[ ! "$USE_REPLICA" ]] && skip "skipped for pocketic: bitcoin adapter is a replica implementation detail"
9191
dfx_new hello
9292
dfx_start "--bitcoin-node" "127.0.0.1:18444"
9393

9494
assert_file_not_empty "$E2E_SHARED_LOCAL_NETWORK_DATA_DIRECTORY/ic-btc-adapter-pid"
9595
}
9696

9797
@test "dfx start --enable-bitcoin with no other configuration succeeds" {
98-
[[ "$USE_POCKETIC" ]] && skip "skipped for pocketic: bitcoin adapter is a replica implementation detail"
98+
[[ ! "$USE_REPLICA" ]] && skip "skipped for pocketic: bitcoin adapter is a replica implementation detail"
9999
dfx_new hello
100100

101101
dfx_start --enable-bitcoin
@@ -114,7 +114,7 @@ set_local_network_bitcoin_enabled() {
114114
}
115115

116116
@test "can enable bitcoin through default configuration - dfx start" {
117-
[[ "$USE_POCKETIC" ]] && skip "skipped for pocketic: bitcoin adapter is a replica implementation detail"
117+
[[ ! "$USE_REPLICA" ]] && skip "skipped for pocketic: bitcoin adapter is a replica implementation detail"
118118
dfx_new hello
119119
define_project_network
120120
set_project_default_bitcoin_enabled
@@ -125,7 +125,7 @@ set_local_network_bitcoin_enabled() {
125125
}
126126

127127
@test "can enable bitcoin through shared local network - dfx start" {
128-
[[ "$USE_POCKETIC" ]] && skip "skipped for pocketic: bitcoin adapter is a replica implementation detail"
128+
[[ ! "$USE_REPLICA" ]] && skip "skipped for pocketic: bitcoin adapter is a replica implementation detail"
129129
dfx_new hello
130130
set_shared_local_network_bitcoin_enabled
131131

@@ -135,7 +135,7 @@ set_local_network_bitcoin_enabled() {
135135
}
136136

137137
@test "can enable bitcoin through local network configuration - dfx start" {
138-
[[ "$USE_POCKETIC" ]] && skip "skipped for pocketic: bitcoin adapter is a replica implementation detail"
138+
[[ ! "$USE_REPLICA" ]] && skip "skipped for pocketic: bitcoin adapter is a replica implementation detail"
139139
dfx_new hello
140140
set_local_network_bitcoin_enabled
141141

@@ -145,7 +145,7 @@ set_local_network_bitcoin_enabled() {
145145
}
146146

147147
@test "dfx start with both bitcoin and canister http enabled" {
148-
[[ "$USE_POCKETIC" ]] && skip "skipped for pocketic: bitcoin adapter is a replica implementation detail"
148+
[[ ! "$USE_REPLICA" ]] && skip "skipped for pocketic: bitcoin adapter is a replica implementation detail"
149149
dfx_new hello
150150

151151
dfx_start --enable-bitcoin --enable-canister-http

e2e/tests-dfx/call.bash

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ teardown() {
199199
dfx canister create --all
200200
dfx build
201201
dfx canister install hello_backend
202-
[[ "$USE_POCKETIC" ]] && dfx ledger fabricate-cycles --t 9999999 --canister hello_backend
202+
[[ ! "$USE_REPLICA" ]] && dfx ledger fabricate-cycles --t 9999999 --canister hello_backend
203203
assert_command dfx canister call hello_backend recurse 100
204204
}
205205

@@ -369,13 +369,13 @@ function impersonate_sender() {
369369
}
370370

371371
@test "impersonate management canister as sender" {
372-
[[ ! "$USE_POCKETIC" ]] && skip "skipped for replica: impersonating sender is only supported for PocketIC"
372+
[[ "$USE_REPLICA" ]] && skip "skipped for replica: impersonating sender is only supported for PocketIC"
373373

374374
impersonate_sender "aaaaa-aa"
375375
}
376376

377377
@test "impersonate new random identity as sender" {
378-
[[ ! "$USE_POCKETIC" ]] && skip "skipped for replica: impersonating sender is only supported for PocketIC"
378+
[[ "$USE_REPLICA" ]] && skip "skipped for replica: impersonating sender is only supported for PocketIC"
379379

380380
dfx identity new impersonated_identity --storage-mode plaintext
381381
IDENTITY_PRINCIPAL="$(dfx --identity impersonated_identity identity get-principal)"

e2e/tests-dfx/create.bash

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ teardown() {
4343
}
4444

4545
@test "create succeeds when specify large canister ID" {
46-
[[ "$USE_POCKETIC" ]] && skip "skipped for pocketic: nonexistent subnet ranges are unsupported"
46+
[[ ! "$USE_REPLICA" ]] && skip "skipped for pocketic: nonexistent subnet ranges are unsupported"
4747
dfx_start
4848
# hhn2s-5l777-77777-7777q-cai is the canister ID of (u64::MAX / 2)
4949
assert_command dfx canister create e2e_project_backend --specified-id hhn2s-5l777-77777-7777q-cai
@@ -56,7 +56,7 @@ teardown() {
5656
# nojwb-ieaaa-aaaaa-aaaaa-cai is the canister ID of (u64::MAX / 2 + 1)
5757
assert_command_fail dfx canister create e2e_project_backend --specified-id nojwb-ieaaa-aaaaa-aaaaa-cai
5858

59-
if [[ "$USE_POCKETIC" ]]; then
59+
if [[ ! "$USE_REPLICA" ]]; then
6060
assert_match "The effective canister ID nojwb-ieaaa-aaaaa-aaaaa-cai does not belong to an existing subnet and it is not a mainnet canister ID."
6161
else
6262
assert_match "Specified CanisterId nojwb-ieaaa-aaaaa-aaaaa-cai is not hosted by subnet"
@@ -407,7 +407,7 @@ function textual_decode() {
407407
}
408408

409409
@test "create targets application subnet in PocketIC" {
410-
[[ ! "$USE_POCKETIC" ]] && skip "skipped for replica: no support for multiple subnets"
410+
[[ "$USE_REPLICA" ]] && skip "skipped for replica: no support for multiple subnets"
411411
dfx_start
412412
# create the backend canister without a wallet canister so that the backend canister is the only canister ever created
413413
assert_command dfx canister create e2e_project_backend --no-wallet

e2e/tests-dfx/info.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ teardown() {
1515
}
1616

1717
@test "displays the replica port" {
18-
if [[ "$USE_POCKETIC" ]]
18+
if [[ ! "$USE_REPLICA" ]]
1919
then
2020
assert_command_fail dfx info pocketic-config-port
2121
assert_contains "No PocketIC port found"

e2e/tests-dfx/ledger.bash

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ load ../utils/_
55
install_nns() {
66
dfx_start_for_nns_install
77

8-
dfx extension install nns --version 0.4.3
8+
dfx extension install nns --version 0.5.0
99
dfx nns install --ledger-accounts 345f723e9e619934daac6ae0f4be13a7b0ba57d6a608e511a00fd0ded5866752 22ca7edac648b814e81d7946e8bacea99280e07c5f51a04ba7a38009d8ad8e89 5a94fe181e9d411c58726cb87cbf2d016241b6c350bc3330e4869ca76e54ecbc
1010
}
1111

@@ -158,10 +158,10 @@ tc_to_num() {
158158
balance=$(tc_to_num "$(dfx wallet balance)")
159159

160160
assert_command dfx ledger top-up "$wallet" --icp 5
161-
assert_match "Canister was topped up with 617283500000000 cycles"
161+
assert_match "Canister was topped up with 500000000000000 cycles"
162162
balance_now=$(tc_to_num "$(dfx wallet balance)")
163163

164-
(( balance_now - balance > 600000000000000 ))
164+
(( balance_now - balance > 400000000000000 ))
165165

166166
# Transaction Deduplication
167167
t=$(current_time_nanoseconds)
@@ -204,7 +204,7 @@ tc_to_num() {
204204
dfx_new
205205
assert_command dfx canister create e2e_project_backend
206206
assert_command dfx ledger top-up e2e_project_backend --amount 5
207-
assert_contains "Canister was topped up with 617283500000000 cycles"
207+
assert_contains "Canister was topped up with 500000000000000 cycles"
208208
}
209209

210210
@test "ledger create-canister" {

e2e/tests-dfx/playground.bash

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ setup_playground() {
4747

4848
@test "canister lifecycle" {
4949
assert_command dfx canister create --all --playground
50-
[[ "$USE_POCKETIC" ]] && dfx ledger fabricate-cycles --t 9999999 --canister hello_backend --playground
51-
[[ "$USE_POCKETIC" ]] && dfx ledger fabricate-cycles --t 9999999 --canister hello_frontend --playground
50+
[[ ! "$USE_REPLICA" ]] && dfx ledger fabricate-cycles --t 9999999 --canister hello_backend --playground
51+
[[ ! "$USE_REPLICA" ]] && dfx ledger fabricate-cycles --t 9999999 --canister hello_frontend --playground
5252

5353
assert_command dfx deploy --playground
5454
assert_command dfx canister --playground call hello_backend greet '("player")'
@@ -81,9 +81,9 @@ setup_playground() {
8181
rm -rf hello
8282
dfx_new_frontend hello
8383

84-
[[ "$USE_POCKETIC" ]] && assert_command dfx canister create --all --playground
85-
[[ "$USE_POCKETIC" ]] && assert_command dfx ledger fabricate-cycles --t 9999999 --canister hello_backend --playground
86-
[[ "$USE_POCKETIC" ]] && assert_command dfx ledger fabricate-cycles --t 9999999 --canister hello_frontend --playground
84+
[[ ! "$USE_REPLICA" ]] && assert_command dfx canister create --all --playground
85+
[[ ! "$USE_REPLICA" ]] && assert_command dfx ledger fabricate-cycles --t 9999999 --canister hello_backend --playground
86+
[[ ! "$USE_REPLICA" ]] && assert_command dfx ledger fabricate-cycles --t 9999999 --canister hello_frontend --playground
8787

8888
assert_command dfx deploy --playground
8989
assert_command dfx canister --playground call hello_backend greet '("player")'
@@ -107,8 +107,8 @@ setup_playground() {
107107
# instrument the asset canister during upload which would run into execution limits.
108108
@test "playground-installed asset canister is same wasm as normal asset canister" {
109109
assert_command dfx canister create --all --playground
110-
[[ "$USE_POCKETIC" ]] && dfx ledger fabricate-cycles --t 9999999 --canister hello_backend --playground
111-
[[ "$USE_POCKETIC" ]] && dfx ledger fabricate-cycles --t 9999999 --canister hello_frontend --playground
110+
[[ ! "$USE_REPLICA" ]] && dfx ledger fabricate-cycles --t 9999999 --canister hello_backend --playground
111+
[[ ! "$USE_REPLICA" ]] && dfx ledger fabricate-cycles --t 9999999 --canister hello_frontend --playground
112112

113113
assert_command dfx deploy --playground
114114
PLAYGROUND_HASH=$(dfx canister --playground info hello_frontend | grep hash)
@@ -120,8 +120,8 @@ setup_playground() {
120120

121121
@test "playground canister upgrades work with Motoko Enhanced Orthogonal Persistence" {
122122
assert_command dfx canister create --all --playground
123-
[[ "$USE_POCKETIC" ]] && dfx ledger fabricate-cycles --t 9999999 --canister hello_backend --playground
124-
[[ "$USE_POCKETIC" ]] && dfx ledger fabricate-cycles --t 9999999 --canister hello_frontend --playground
123+
[[ ! "$USE_REPLICA" ]] && dfx ledger fabricate-cycles --t 9999999 --canister hello_backend --playground
124+
[[ ! "$USE_REPLICA" ]] && dfx ledger fabricate-cycles --t 9999999 --canister hello_frontend --playground
125125

126126
# enable EOP
127127
jq '.canisters.hello_backend.args="--enhanced-orthogonal-persistence"' dfx.json | sponge dfx.json

0 commit comments

Comments
 (0)