 
     broadcast = process.env.GPH_TEST_NO_BROADCAST is undefined
     genesis_private = PrivateKey.fromWif "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"
-    #genesis_active_1_3_0_public = PublicKey.fromBtsPublic "GPH6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV"
     api = null
     
     before (done)->
-        api = ApiInstances.instance()
-        api.init_promise.then ()->
-            done()
-        .catch th.log_error
+        iDB.init_instance(fakeIndexedDB).init_promise.then () ->
+            #PrivateKeyStore.loadDbData().then ()->
+            api = ApiInstances.instance()
+            api.init_promise.then ()->
+                done()
+            .catch th.log_error
     
-    after ->
+    after (done)->
+        iDB.instance().db().close()
+        fakeIndexedDB.deleteDatabase("graphene_db")
         api.close()
+        done()
     
     it "wallet.account_create", (done)->
         suffix = secureRandom.randomBuffer(2).toString('hex').toLowerCase()


ApiInstances = require('../src/rpc_api/ApiInstances')
WalletApi = require '../src/rpc_api/WalletApi'
ApplicationApi = require '../src/rpc_api/ApplicationApi'
wallet = new WalletApi()
app = new ApplicationApi()

###
import_key "1.2.15" "5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3"

    
    #it "update account transaction", ->
    it "wallet.transfer nomemo", (done)->
        helper.test_wallet().then (suffix)=>
            wallet.transfer(
                "1.2.15", "1.2.14", 1, "1.3.0", memo = null
                broadcast, encrypt_memo = no
            ).then (result)->
                #th.print_result result
                #th.print_hex ""
                done()
            .catch th.log_error
        return
    
    it "wallet.transfer encmemo", (done)->
        helper.test_wallet().then (suffix)=>
            wallet.transfer(
                "1.2.15", "1.2.14", 1, "1.3.0", memo = "memo"
                broadcast
            ).then (result)->
                #th.print_result result
                #th.print_hex ""
                done()
            .catch th.log_error
        return
    
    # Aes.encrypt data is not matching c++
    it "wallet encmemo_format", ()->
        sender = PrivateKey.fromSeed("1")
        receiver = PrivateKey.fromSeed("2")
        enc_hex = Aes.encrypt_with_checksum(
            sender
            receiver.toPublicKey()
            nonce = 12345
            "Hello, world!"
        )
        #console.log('... enc_hex',enc_hex.toString('hex'))
        memo={
            from: sender.toPublicKey()
            to: receiver.toPublicKey()
            nonce: 12345
            message: new Buffer(enc_hex, 'hex')
        }
        enc_buffer = hash.sha256 so_type.memo_data.toBuffer memo
        assert.equal(
            enc_buffer.toString('hex')
            "8de72a07d093a589f574460deb19023b4aff354b561eb34590d9f4629f51dbf3"
        )
        assert.equal(
            Aes.decrypt_with_checksum(
                receiver
                sender.toPublicKey()
                nonce = 12345
                enc_hex
            )
            "Hello, world!"
        )
        return
    
    ###
