6

I am making use of JS tests to check my contract calls however there is a large amount of setup required before each test. This means the tests take a very long time to run. I know the substrate database is stored temporarily on disk:

ls -larth /tmp/substratebziLB2/chains/dev/db/full
total 30M
drwxr-xr-x 3 root root 4.0K Mar 22 09:28 ..
-rw-r--r-- 1 root root    0 Mar 22 09:28 LOCK
-rw-r--r-- 1 root root   36 Mar 22 09:28 IDENTITY
-rw-r--r-- 1 root root   16 Mar 22 09:28 CURRENT
-rw-r--r-- 1 root root  51K Mar 22 09:28 OPTIONS-000035
-rw-r--r-- 1 root root  55K Mar 22 09:28 OPTIONS-000037
-rw-r--r-- 1 root root    1 Mar 22 09:28 db_version
-rw-r--r-- 1 root root 4.1M Mar 22 09:48 000038.log
-rw-r--r-- 1 root root 5.2M Mar 22 09:48 000009.log
-rw-r--r-- 1 root root 4.2M Mar 22 10:07 000041.log
-rw-r--r-- 1 root root 4.1M Mar 22 10:07 000039.log
-rw-r--r-- 1 root root 335K Mar 22 10:07 000044.sst
-rw-r--r-- 1 root root 184K Mar 22 10:27 000047.sst
drwxr-xr-x 2 root root 4.0K Mar 22 10:27 .
-rw-r--r-- 1 root root 1.2K Mar 22 10:27 MANIFEST-000008
-rw-r--r-- 1 root root 4.1M Mar 22 10:27 000045.log
-rw-r--r-- 1 root root 4.3M Mar 22 10:27 000042.log
-rw-r--r-- 1 root root 310K Mar 22 10:28 LOG
-rw-r--r-- 1 root root 3.1M Mar 22 10:34 000046.log

What is the process for creating a snapshot of the database and reloading at runtime? I'm assuming something like:

  1. Copy the entire folder substratebziLB2 to /some/path/substratebziLB2
  2. Then specify --base-path /some/path/substratebziLB2 when running substrate

Is this correct?

Are there any problems with this strategy?

3
  • 2
    I updated my reply here, approach 3. and 4. should work for you. Mar 22, 2022 at 11:38
  • Thanks. To clarify, will 4. work with the default substrate node as well? I'm not running a polkadot node so wouldn't expect substrate to look for a chain in ~/.local/share/polkadot/chains/.
    – forgetso
    Mar 22, 2022 at 13:48
  • 1
    Added it, thanks. You would need to pass in the --base-path flag, the it should work. So for example substrate --dev --base-path /tmp/my_substrate. Mar 22, 2022 at 14:06

0

Browse other questions tagged or ask your own question.