def scenario(wallets, **kw):

    global value_hashes

    testlib.blockstack_namespace_preorder("test", wallets[1].addr,
                                          wallets[0].privkey)
    testlib.next_block(**kw)

    testlib.blockstack_namespace_reveal(
        "test", wallets[1].addr, 52595, 250, 4,
        [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10,
        wallets[0].privkey)
    testlib.next_block(**kw)

    testlib.blockstack_namespace_ready("test", wallets[1].privkey)
    testlib.next_block(**kw)

    # register 10 names
    for i in xrange(0, 10):
        res = testlib.blockstack_name_preorder("foo_{}.test".format(i),
                                               wallets[2].privkey,
                                               wallets[3].addr)
        if 'error' in res:
            print json.dumps(res)
            return False

    testlib.next_block(**kw)

    # make some subdomains
    zf_template = "$ORIGIN {}\n$TTL 3600\n{}"
    zf_default_url = '_https._tcp URI 10 1 "https://raw.githubusercontent.com/nobody/content/profile.md"'

    zonefiles = {
        'foo_0.test':
        zf_template.format(
            'foo_0.test',
            subdomains.make_subdomain_txt(
                'bar.foo_0.test', 'foo_0.test', wallets[4].addr, 0,
                zf_template.format('bar.foo_0.test', zf_default_url),
                wallets[4].privkey)),
        'foo_1.test':
        zf_template.format(
            'foo_1.test',
            subdomains.make_subdomain_txt(
                'bar.foo_1.test', 'foo_1.test', wallets[4].addr, 0,
                zf_template.format('bar.foo_1.test', zf_default_url),
                wallets[4].privkey)),
        'foo_2.test':
        zf_template.format(
            'foo_2.test',
            subdomains.make_subdomain_txt(
                'bar.foo_2.test', 'foo_2.test', wallets[4].addr, 0,
                zf_template.format('bar.foo_2.test', zf_default_url),
                wallets[4].privkey)),
        'foo_3.test':
        zf_template.format(
            'foo_3.test',
            subdomains.make_subdomain_txt(
                'bar.foo_3.test', 'foo_3.test', wallets[4].addr, 0,
                zf_template.format('bar.foo_3.test', zf_default_url),
                wallets[4].privkey)),
        'foo_4.test':
        zf_template.format(
            'foo_4.test',
            subdomains.make_subdomain_txt(
                'bar.foo_4.test', 'foo_4.test', wallets[4].addr, 0,
                zf_template.format('bar.foo_4.test', zf_default_url),
                wallets[4].privkey)),
        'foo_5.test':
        zf_template.format(
            'foo_5.test',
            subdomains.make_subdomain_txt(
                'bar.foo_5.test', 'foo_5.test', wallets[4].addr, 0,
                zf_template.format('bar.foo_5.test', zf_default_url),
                wallets[4].privkey)),
        'foo_6.test':
        zf_template.format(
            'foo_6.test',
            subdomains.make_subdomain_txt(
                'bar.foo_6.test', 'foo_6.test', wallets[4].addr, 0,
                zf_template.format('bar.foo_6.test', zf_default_url),
                wallets[4].privkey)),
        'foo_7.test':
        zf_template.format(
            'foo_7.test',
            subdomains.make_subdomain_txt(
                'bar.foo_7.test', 'foo_7.test', wallets[4].addr, 0,
                zf_template.format('bar.foo_7.test', zf_default_url),
                wallets[4].privkey)),
        'foo_8.test':
        zf_template.format(
            'foo_8.test',
            subdomains.make_subdomain_txt(
                'bar.foo_8.test', 'foo_8.test', wallets[4].addr, 0,
                zf_template.format('bar.foo_8.test', zf_default_url),
                wallets[4].privkey)),
        'foo_9.test':
        zf_template.format(
            'foo_9.test',
            subdomains.make_subdomain_txt(
                'bar.foo_9.test', 'foo_9.test', wallets[4].addr, 0,
                zf_template.format('bar.foo_9.test', zf_default_url),
                wallets[4].privkey)),
    }

    for i in xrange(0, 10):
        res = testlib.blockstack_name_register(
            "foo_{}.test".format(i),
            wallets[2].privkey,
            wallets[3].addr,
            zonefile_hash=blockstack.lib.storage.get_zonefile_data_hash(
                zonefiles['foo_{}.test'.format(i)]))
        if 'error' in res:
            print json.dumps(res)
            return False

    testlib.next_block(**kw)

    # propagate
    for name in zonefiles:
        assert testlib.blockstack_put_zonefile(zonefiles[name])

    # process subdomains
    testlib.next_block(**kw)

    print 'waiting for all zone files to replicate'
    time.sleep(10)

    config_path = os.environ.get("BLOCKSTACK_CLIENT_CONFIG")
    assert config_path
    restore_dir = os.path.join(os.path.dirname(config_path), "snapshot_dir")

    # snapshot the latest backup
    snapshot_path = os.path.join(os.path.dirname(config_path), "snapshot.bsk")
    rc = blockstack.fast_sync_snapshot(kw['working_dir'], snapshot_path,
                                       wallets[3].privkey, None)
    if not rc:
        print "Failed to fast_sync_snapshot"
        return False

    if not os.path.exists(snapshot_path):
        print "Failed to create snapshot {}".format(snapshot_path)
        return False

    # sign with more keys
    for i in xrange(4, 6):
        rc = blockstack.fast_sync_sign_snapshot(snapshot_path,
                                                wallets[i].privkey)
        if not rc:
            print "Failed to sign with key {}".format(i)
            return False

    # restore!
    rc = restore(
        kw['working_dir'], snapshot_path, restore_dir,
        [wallets[3].pubkey_hex, wallets[4].pubkey_hex, wallets[5].pubkey_hex],
        3)
    if not rc:
        print "failed to restore snapshot {}".format(snapshot_path)
        return False

    rc = restore(
        kw['working_dir'], snapshot_path, restore_dir,
        [wallets[5].pubkey_hex, wallets[4].pubkey_hex, wallets[3].pubkey_hex],
        3)
    if not rc:
        print "failed to restore snapshot {}".format(snapshot_path)
        return False

    rc = restore(kw['working_dir'], snapshot_path, restore_dir,
                 [wallets[3].pubkey_hex, wallets[4].pubkey_hex], 2)
    if not rc:
        print "failed to restore snapshot {}".format(snapshot_path)
        return False

    rc = restore(kw['working_dir'], snapshot_path, restore_dir,
                 [wallets[3].pubkey_hex, wallets[5].pubkey_hex], 2)
    if not rc:
        print "failed to restore snapshot {}".format(snapshot_path)
        return False

    rc = restore(kw['working_dir'], snapshot_path, restore_dir,
                 [wallets[4].pubkey_hex, wallets[5].pubkey_hex], 2)
    if not rc:
        print "failed to restore snapshot {}".format(snapshot_path)
        return False

    rc = restore(kw['working_dir'], snapshot_path, restore_dir,
                 [wallets[3].pubkey_hex], 1)
    if not rc:
        print "failed to restore snapshot {}".format(snapshot_path)
        return False

    rc = restore(kw['working_dir'], snapshot_path, restore_dir,
                 [wallets[4].pubkey_hex, wallets[0].pubkey_hex], 1)
    if not rc:
        print "failed to restore snapshot {}".format(snapshot_path)
        return False

    rc = restore(
        kw['working_dir'], snapshot_path, restore_dir,
        [wallets[0].pubkey_hex, wallets[1].pubkey_hex, wallets[5].pubkey_hex],
        1)
    if not rc:
        print "failed to restore snapshot {}".format(snapshot_path)
        return False

    # should fail
    rc = restore(kw['working_dir'], snapshot_path, restore_dir,
                 [wallets[3].pubkey_hex], 2)
    if rc:
        print "restored insufficient signatures snapshot {}".format(
            snapshot_path)
        return False

    shutil.rmtree(restore_dir)

    # should fail
    rc = restore(kw['working_dir'], snapshot_path, restore_dir,
                 [wallets[3].pubkey_hex, wallets[4].pubkey_hex], 3)
    if rc:
        print "restored insufficient signatures snapshot {}".format(
            snapshot_path)
        return False

    shutil.rmtree(restore_dir)

    # should fail
    rc = restore(kw['working_dir'], snapshot_path, restore_dir,
                 [wallets[0].pubkey_hex], 1)
    if rc:
        print "restored wrongly-signed snapshot {}".format(snapshot_path)
        return False

    shutil.rmtree(restore_dir)

    # should fail
    rc = restore(kw['working_dir'], snapshot_path, restore_dir,
                 [wallets[0].pubkey_hex, wallets[3].pubkey_hex], 2)
    if rc:
        print "restored wrongly-signed snapshot {}".format(snapshot_path)
        return False

    shutil.rmtree(restore_dir)

    # should fail
    rc = restore(
        kw['working_dir'], snapshot_path, restore_dir,
        [wallets[0].pubkey_hex, wallets[3].pubkey_hex, wallets[4].pubkey_hex],
        3)
    if rc:
        print "restored wrongly-signed snapshot {}".format(snapshot_path)
        return False

    shutil.rmtree(restore_dir)
Пример #2
0
    def _backup_and_restore():
        # snapshot the latest backup
        snapshot_path = os.path.join(working_dir, "snapshot.bsk")
        rc = blockstack.fast_sync_snapshot(working_dir, snapshot_path,
                                           wallets[3].privkey, None)
        if not rc:
            print "Failed to fast_sync_snapshot"
            return False

        if not os.path.exists(snapshot_path):
            print "Failed to create snapshot {}".format(snapshot_path)
            return False

        # sign with more keys
        for i in xrange(4, 6):
            rc = blockstack.fast_sync_sign_snapshot(snapshot_path,
                                                    wallets[i].privkey)
            if not rc:
                print "Failed to sign with key {}".format(i)
                return False

        # restore!
        rc = restore(kw['working_dir'], snapshot_path, restore_dir, [
            wallets[3].pubkey_hex, wallets[4].pubkey_hex, wallets[5].pubkey_hex
        ], 3)
        if not rc:
            print "1 failed to restore snapshot {}".format(snapshot_path)
            return False

        rc = restore(kw['working_dir'], snapshot_path, restore_dir, [
            wallets[5].pubkey_hex, wallets[4].pubkey_hex, wallets[3].pubkey_hex
        ], 3)
        if not rc:
            print "2 failed to restore snapshot {}".format(snapshot_path)
            return False

        rc = restore(kw['working_dir'], snapshot_path, restore_dir,
                     [wallets[3].pubkey_hex, wallets[4].pubkey_hex], 2)
        if not rc:
            print "3 failed to restore snapshot {}".format(snapshot_path)
            return False

        rc = restore(kw['working_dir'], snapshot_path, restore_dir,
                     [wallets[3].pubkey_hex, wallets[5].pubkey_hex], 2)
        if not rc:
            print "4 failed to restore snapshot {}".format(snapshot_path)
            return False

        rc = restore(kw['working_dir'], snapshot_path, restore_dir,
                     [wallets[4].pubkey_hex, wallets[5].pubkey_hex], 2)
        if not rc:
            print "5 failed to restore snapshot {}".format(snapshot_path)
            return False

        rc = restore(kw['working_dir'], snapshot_path, restore_dir,
                     [wallets[3].pubkey_hex], 1)
        if not rc:
            print "6 failed to restore snapshot {}".format(snapshot_path)
            return False

        rc = restore(kw['working_dir'], snapshot_path, restore_dir,
                     [wallets[4].pubkey_hex, wallets[0].pubkey_hex], 1)
        if not rc:
            print "7 failed to restore snapshot {}".format(snapshot_path)
            return False

        rc = restore(kw['working_dir'], snapshot_path, restore_dir, [
            wallets[0].pubkey_hex, wallets[1].pubkey_hex, wallets[5].pubkey_hex
        ], 1)
        if not rc:
            print "8 failed to restore snapshot {}".format(snapshot_path)
            return False

        shutil.move(restore_dir, restore_dir + '.bak')

        # should fail
        rc = restore(kw['working_dir'], snapshot_path, restore_dir,
                     [wallets[3].pubkey_hex], 2)
        if rc:
            print "restored insufficient signatures snapshot {}".format(
                snapshot_path)
            return False

        shutil.rmtree(restore_dir)

        # should fail
        rc = restore(kw['working_dir'], snapshot_path, restore_dir,
                     [wallets[3].pubkey_hex, wallets[4].pubkey_hex], 3)
        if rc:
            print "restored insufficient signatures snapshot {}".format(
                snapshot_path)
            return False

        shutil.rmtree(restore_dir)

        # should fail
        rc = restore(kw['working_dir'], snapshot_path, restore_dir,
                     [wallets[0].pubkey_hex], 1)
        if rc:
            print "restored wrongly-signed snapshot {}".format(snapshot_path)
            return False

        shutil.rmtree(restore_dir)

        # should fail
        rc = restore(kw['working_dir'], snapshot_path, restore_dir,
                     [wallets[0].pubkey_hex, wallets[3].pubkey_hex], 2)
        if rc:
            print "restored wrongly-signed snapshot {}".format(snapshot_path)
            return False

        shutil.rmtree(restore_dir)

        # should fail
        rc = restore(kw['working_dir'], snapshot_path, restore_dir, [
            wallets[0].pubkey_hex, wallets[3].pubkey_hex, wallets[4].pubkey_hex
        ], 3)
        if rc:
            print "restored wrongly-signed snapshot {}".format(snapshot_path)
            return False

        shutil.rmtree(restore_dir)
        shutil.move(restore_dir + '.bak', restore_dir)
        return True
def scenario(wallets, **kw):

    global value_hashes

    testlib.blockstack_namespace_preorder("test", wallets[1].addr,
                                          wallets[0].privkey)
    testlib.next_block(**kw)

    testlib.blockstack_namespace_reveal(
        "test", wallets[1].addr, 52595, 250, 4,
        [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10,
        wallets[0].privkey)
    testlib.next_block(**kw)

    testlib.blockstack_namespace_ready("test", wallets[1].privkey)
    testlib.next_block(**kw)

    # register 10 names
    for i in xrange(0, 10):
        res = testlib.blockstack_name_preorder("foo_{}.test".format(i),
                                               wallets[2].privkey,
                                               wallets[3].addr)
        if 'error' in res:
            print json.dumps(res)
            return False

    testlib.next_block(**kw)

    for i in xrange(0, 10):
        res = testlib.blockstack_name_register("foo_{}.test".format(i),
                                               wallets[2].privkey,
                                               wallets[3].addr)
        if 'error' in res:
            print json.dumps(res)
            return False

    testlib.next_block(**kw)

    # make 10 empty zonefiles and propagate them
    for i in xrange(0, 10):
        data_pubkey = wallets[4].pubkey_hex
        empty_zonefile = blockstack_client.zonefile.make_empty_zonefile(
            "foo_{}.test".format(i),
            data_pubkey,
            urls=["file:///tmp/foo_{}.test".format(i)])
        empty_zonefile_str = blockstack_zones.make_zone_file(empty_zonefile)
        value_hash = blockstack_client.hash_zonefile(empty_zonefile)

        res = testlib.blockstack_name_update("foo_{}.test".format(i),
                                             value_hash, wallets[3].privkey)
        if 'error' in res:
            print json.dumps(res)
            return False

        testlib.next_block(**kw)

        res = testlib.blockstack_put_zonefile(empty_zonefile_str)
        if not res:
            return False

        value_hashes.append(value_hash)

    testlib.next_block(**kw)

    print 'waiting for all zone files to replicate'
    time.sleep(10)

    config_path = os.environ.get("BLOCKSTACK_CLIENT_CONFIG")
    assert config_path
    restore_dir = os.path.join(os.path.dirname(config_path), "snapshot_dir")

    # snapshot the latest backup
    snapshot_path = os.path.join(os.path.dirname(config_path), "snapshot.bsk")
    rc = blockstack.fast_sync_snapshot(kw['working_dir'], snapshot_path,
                                       wallets[3].privkey, None)
    if not rc:
        print "Failed to fast_sync_snapshot"
        return False

    if not os.path.exists(snapshot_path):
        print "Failed to create snapshot {}".format(snapshot_path)
        return False

    # sign with more keys
    for i in xrange(4, 6):
        rc = blockstack.fast_sync_sign_snapshot(snapshot_path,
                                                wallets[i].privkey)
        if not rc:
            print "Failed to sign with key {}".format(i)
            return False

    # restore!
    rc = restore(
        kw['working_dir'], snapshot_path, restore_dir,
        [wallets[3].pubkey_hex, wallets[4].pubkey_hex, wallets[5].pubkey_hex],
        3)
    if not rc:
        print "failed to restore snapshot {}".format(snapshot_path)
        return False

    rc = restore(
        kw['working_dir'], snapshot_path, restore_dir,
        [wallets[5].pubkey_hex, wallets[4].pubkey_hex, wallets[3].pubkey_hex],
        3)
    if not rc:
        print "failed to restore snapshot {}".format(snapshot_path)
        return False

    rc = restore(kw['working_dir'], snapshot_path, restore_dir,
                 [wallets[3].pubkey_hex, wallets[4].pubkey_hex], 2)
    if not rc:
        print "failed to restore snapshot {}".format(snapshot_path)
        return False

    rc = restore(kw['working_dir'], snapshot_path, restore_dir,
                 [wallets[3].pubkey_hex, wallets[5].pubkey_hex], 2)
    if not rc:
        print "failed to restore snapshot {}".format(snapshot_path)
        return False

    rc = restore(kw['working_dir'], snapshot_path, restore_dir,
                 [wallets[4].pubkey_hex, wallets[5].pubkey_hex], 2)
    if not rc:
        print "failed to restore snapshot {}".format(snapshot_path)
        return False

    rc = restore(kw['working_dir'], snapshot_path, restore_dir,
                 [wallets[3].pubkey_hex], 1)
    if not rc:
        print "failed to restore snapshot {}".format(snapshot_path)
        return False

    rc = restore(kw['working_dir'], snapshot_path, restore_dir,
                 [wallets[4].pubkey_hex, wallets[0].pubkey_hex], 1)
    if not rc:
        print "failed to restore snapshot {}".format(snapshot_path)
        return False

    rc = restore(
        kw['working_dir'], snapshot_path, restore_dir,
        [wallets[0].pubkey_hex, wallets[1].pubkey_hex, wallets[5].pubkey_hex],
        1)
    if not rc:
        print "failed to restore snapshot {}".format(snapshot_path)
        return False

    # should fail
    rc = restore(kw['working_dir'], snapshot_path, restore_dir,
                 [wallets[3].pubkey_hex], 2)
    if rc:
        print "restored insufficient signatures snapshot {}".format(
            snapshot_path)
        return False

    shutil.rmtree(restore_dir)

    # should fail
    rc = restore(kw['working_dir'], snapshot_path, restore_dir,
                 [wallets[3].pubkey_hex, wallets[4].pubkey_hex], 3)
    if rc:
        print "restored insufficient signatures snapshot {}".format(
            snapshot_path)
        return False

    shutil.rmtree(restore_dir)

    # should fail
    rc = restore(kw['working_dir'], snapshot_path, restore_dir,
                 [wallets[0].pubkey_hex], 1)
    if rc:
        print "restored wrongly-signed snapshot {}".format(snapshot_path)
        return False

    shutil.rmtree(restore_dir)

    # should fail
    rc = restore(kw['working_dir'], snapshot_path, restore_dir,
                 [wallets[0].pubkey_hex, wallets[3].pubkey_hex], 2)
    if rc:
        print "restored wrongly-signed snapshot {}".format(snapshot_path)
        return False

    shutil.rmtree(restore_dir)

    # should fail
    rc = restore(
        kw['working_dir'], snapshot_path, restore_dir,
        [wallets[0].pubkey_hex, wallets[3].pubkey_hex, wallets[4].pubkey_hex],
        3)
    if rc:
        print "restored wrongly-signed snapshot {}".format(snapshot_path)
        return False

    shutil.rmtree(restore_dir)
def scenario( wallets, **kw ):

    global value_hashes

    testlib.blockstack_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey )
    testlib.next_block( **kw )

    testlib.blockstack_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey )
    testlib.next_block( **kw )

    testlib.blockstack_namespace_ready( "test", wallets[1].privkey )
    testlib.next_block( **kw )

    # register 10 names
    for i in xrange(0, 10):
        res = testlib.blockstack_name_preorder( "foo_{}.test".format(i), wallets[2].privkey, wallets[3].addr )
        if 'error' in res:
            print json.dumps(res)
            return False

    testlib.next_block( **kw )
    
    for i in xrange(0, 10):
        res = testlib.blockstack_name_register( "foo_{}.test".format(i), wallets[2].privkey, wallets[3].addr )
        if 'error' in res:
            print json.dumps(res)
            return False

    testlib.next_block( **kw )
 
    # make 10 empty zonefiles and propagate them 
    for i in xrange(0, 10):
        data_pubkey = wallets[4].pubkey_hex
        empty_zonefile = blockstack_client.zonefile.make_empty_zonefile( "foo_{}.test".format(i), data_pubkey, urls=["file:///tmp/foo_{}.test".format(i)] )
        empty_zonefile_str = blockstack_zones.make_zone_file( empty_zonefile )
        value_hash = blockstack_client.hash_zonefile( empty_zonefile )

        res = testlib.blockstack_name_update( "foo_{}.test".format(i), value_hash, wallets[3].privkey )
        if 'error' in res:
            print json.dumps(res)
            return False

        testlib.next_block( **kw )

        # propagate 
        res = testlib.blockstack_cli_sync_zonefile('foo_{}.test'.format(i), zonefile_string=empty_zonefile_str)
        if 'error' in res:
            print json.dumps(res)
            return False

        value_hashes.append(value_hash)

    config_path = os.environ.get("BLOCKSTACK_CLIENT_CONFIG")
    assert config_path
    restore_dir = os.path.join(os.path.dirname(config_path), "snapshot_dir")

    # snapshot the latest backup
    snapshot_path = os.path.join( os.path.dirname(config_path), "snapshot.bsk" )
    rc = blockstack.fast_sync_snapshot( snapshot_path, wallets[3].privkey, None )
    if not rc:
        print "Failed to fast_sync_snapshot"
        return False
   
    if not os.path.exists(snapshot_path):
        print "Failed to create snapshot {}".format(snapshot_path)
        return False

    # sign with more keys 
    for i in xrange(4, 6):
        rc = blockstack.fast_sync_sign_snapshot( snapshot_path, wallets[i].privkey )
        if not rc:
            print "Failed to sign with key {}".format(i)
            return False

    # restore!
    rc = restore( snapshot_path, restore_dir, [wallets[3].pubkey_hex, wallets[4].pubkey_hex, wallets[5].pubkey_hex], 3 )
    if not rc:
        print "failed to restore snapshot {}".format(snapshot_path)
        return False

    rc = restore( snapshot_path, restore_dir, [wallets[5].pubkey_hex, wallets[4].pubkey_hex, wallets[3].pubkey_hex], 3 )
    if not rc:
        print "failed to restore snapshot {}".format(snapshot_path)
        return False

    rc = restore( snapshot_path, restore_dir, [wallets[3].pubkey_hex, wallets[4].pubkey_hex], 2 )
    if not rc:
        print "failed to restore snapshot {}".format(snapshot_path)
        return False

    rc = restore( snapshot_path, restore_dir, [wallets[3].pubkey_hex, wallets[5].pubkey_hex], 2 )
    if not rc:
        print "failed to restore snapshot {}".format(snapshot_path)
        return False

    rc = restore( snapshot_path, restore_dir, [wallets[4].pubkey_hex, wallets[5].pubkey_hex], 2 )
    if not rc:
        print "failed to restore snapshot {}".format(snapshot_path)
        return False

    rc = restore( snapshot_path, restore_dir, [wallets[3].pubkey_hex], 1 )
    if not rc:
        print "failed to restore snapshot {}".format(snapshot_path)
        return False

    rc = restore( snapshot_path, restore_dir, [wallets[4].pubkey_hex, wallets[0].pubkey_hex], 1 )
    if not rc:
        print "failed to restore snapshot {}".format(snapshot_path)
        return False

    rc = restore( snapshot_path, restore_dir, [wallets[0].pubkey_hex, wallets[1].pubkey_hex, wallets[5].pubkey_hex], 1 )
    if not rc:
        print "failed to restore snapshot {}".format(snapshot_path)
        return False

    # should fail
    rc = restore( snapshot_path, restore_dir, [wallets[3].pubkey_hex], 2 )
    if rc:
        print "restored insufficient signatures snapshot {}".format(snapshot_path)
        return False

    shutil.rmtree(restore_dir)

    # should fail
    rc = restore( snapshot_path, restore_dir, [wallets[3].pubkey_hex, wallets[4].pubkey_hex], 3 )
    if rc:
        print "restored insufficient signatures snapshot {}".format(snapshot_path)
        return False

    shutil.rmtree(restore_dir)

    # should fail
    rc = restore( snapshot_path, restore_dir, [wallets[0].pubkey_hex], 1 )
    if rc:
        print "restored wrongly-signed snapshot {}".format(snapshot_path)
        return False

    shutil.rmtree(restore_dir)

    # should fail
    rc = restore( snapshot_path, restore_dir, [wallets[0].pubkey_hex, wallets[3].pubkey_hex], 2 )
    if rc:
        print "restored wrongly-signed snapshot {}".format(snapshot_path)
        return False

    shutil.rmtree(restore_dir)

    # should fail
    rc = restore( snapshot_path, restore_dir, [wallets[0].pubkey_hex, wallets[3].pubkey_hex, wallets[4].pubkey_hex], 3 )
    if rc:
        print "restored wrongly-signed snapshot {}".format(snapshot_path)
        return False

    shutil.rmtree(restore_dir)