|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +test_description="Test migration 7 to 9" |
| 4 | + |
| 5 | +. lib/test-lib.sh |
| 6 | + |
| 7 | +# Dist specially built with a v0.5.0-dev-8to9pre1 release |
| 8 | +export IPFS_DIST_PATH="/ipfs/QmaaN2kipZfUpRSzwvUeG4Xi3yp1JJB294Vj8pnZ24hesF" |
| 9 | +export GOPATH="$(pwd)/gopath" |
| 10 | +mkdir -p gopath/bin |
| 11 | +export PATH="$(pwd)/../bin:$GOPATH/bin:$PATH" |
| 12 | +echo $IPFS_PATH |
| 13 | + |
| 14 | +test_install_ipfs_nd "v0.4.23" |
| 15 | + |
| 16 | +test_init_ipfs_nd |
| 17 | + |
| 18 | +# We need bootstrap addresses to migrate. These are defaults from v0.4.23. |
| 19 | +test_expect_success "add bootstrap addresses" ' |
| 20 | + test_config_set --json Bootstrap "[ |
| 21 | + \"/dnsaddr/bootstrap.libp2p.io/ipfs/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN\", |
| 22 | + \"/dnsaddr/bootstrap.libp2p.io/ipfs/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa\", |
| 23 | + \"/dnsaddr/bootstrap.libp2p.io/ipfs/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb\", |
| 24 | + \"/dnsaddr/bootstrap.libp2p.io/ipfs/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt\", |
| 25 | + \"/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ\", |
| 26 | + \"/ip4/104.236.179.241/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM\", |
| 27 | + \"/ip4/128.199.219.111/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu\", |
| 28 | + \"/ip4/104.236.76.40/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64\", |
| 29 | + \"/ip4/178.62.158.247/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd\", |
| 30 | + \"/ip6/2604:a880:1:20::203:d001/tcp/4001/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM\", |
| 31 | + \"/ip6/2400:6180:0:d0::151:6001/tcp/4001/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu\", |
| 32 | + \"/ip6/2604:a880:800:10::4a:5001/tcp/4001/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64\", |
| 33 | + \"/ip6/2a03:b0c0:0:1010::23:1001/tcp/4001/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd\" |
| 34 | +]" |
| 35 | +' |
| 36 | + |
| 37 | +test_expect_success "remember old bootstrap" ' |
| 38 | + ipfs config Bootstrap | grep -E -o "Qm[a-zA-Z0-9]+" | sort > bootstrap_old |
| 39 | +' |
| 40 | + |
| 41 | +# no need to launch daemon as this works offline |
| 42 | + |
| 43 | +test_expect_success "add some keys to the keystore" ' |
| 44 | + ipfs key gen -t rsa thisISKey1 && ipfs key gen -t ed25519 key2 |
| 45 | +' |
| 46 | + |
| 47 | +test_expect_success "ipfs key list" ' |
| 48 | + ipfs key list > key_list |
| 49 | +' |
| 50 | + |
| 51 | +test_expect_success "run migration 7 to 8" ' |
| 52 | + ipfs-7-to-8 -verbose -path="$IPFS_PATH" > migration_output8 |
| 53 | +' |
| 54 | + |
| 55 | +test_expect_success "run migration 8 to 9" ' |
| 56 | + ipfs-8-to-9 -verbose -path="$IPFS_PATH" > migration_output9 |
| 57 | +' |
| 58 | + |
| 59 | +test_expect_success "migration processed keys" ' |
| 60 | + grep "thisISKey1" migration_output9 && |
| 61 | + grep "key2" migration_output9 |
| 62 | +' |
| 63 | + |
| 64 | +test_expect_success "migrated files exist" ' |
| 65 | + [ -f "${IPFS_PATH}/keystore/key_orugs42jknfwk6jr" ] && |
| 66 | + [ -f "${IPFS_PATH}/keystore/key_nnsxsmq" ] |
| 67 | +' |
| 68 | + |
| 69 | +test_install_ipfs_nd "v0.5.0-dev-8to9pre2" |
| 70 | + |
| 71 | +test_expect_success "ipfs key list is the same" ' |
| 72 | + ipfs key list > new_key_list |
| 73 | + test_cmp key_list new_key_list |
| 74 | +' |
| 75 | + |
| 76 | +test_expect_success "migration revert to 8 succeeds" ' |
| 77 | + ipfs-8-to-9 -revert -verbose -path="$IPFS_PATH" > revert_output8 |
| 78 | +' |
| 79 | + |
| 80 | +test_expect_success "migration revert to 7 succeeds" ' |
| 81 | + ipfs-7-to-8 -revert -verbose -path="$IPFS_PATH" > revert_output7 |
| 82 | +' |
| 83 | + |
| 84 | +test_install_ipfs_nd "v0.4.23" |
| 85 | + |
| 86 | +test_expect_success "bootstrap addresses were reverted" ' |
| 87 | + ipfs config Bootstrap | grep -E -o "Qm[a-zA-Z0-9]+" | sort > bootstrap_revert |
| 88 | + test_cmp bootstrap_old bootstrap_revert |
| 89 | +' |
| 90 | + |
| 91 | +test_expect_success "ipfs key list is the same after revert" ' |
| 92 | + ipfs key list > revert_key_list |
| 93 | + test_cmp key_list revert_key_list |
| 94 | +' |
| 95 | + |
| 96 | +test_done |
0 commit comments