text: /*
   * ISC License (ISC)
   * Copyright (c) 2018 aeternity developers
   *
   *  Permission to use, copy, modify, and/or distribute this software for any
   *  purpose with or without fee is hereby granted, provided that the above
   *  copyright notice and this permission notice appear in all copies.
   *
   *  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
   *  REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
   *  AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
   *  INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
   *  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
   *  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
   *  PERFORMANCE OF THIS SOFTWARE.
   */
  
  import '../'
  import { describe, it } from 'mocha'
  import MemoryAccount from '../../es/account/memory'
  import { generateKeyPair } from '../../es/utils/crypto'
  
  const testAcc = generateKeyPair()
  
  describe('MemoryAccount', function () {
    describe('Fail on invalid params', () => {
      it('Fail on empty keypair', async () => {
        try {
          MemoryAccount({})
        } catch (e) {
          e.message.should.be.equal('KeyPair must be an object')
        }
      })
      it('Fail on empty keypair object', async () => {
        try {
          MemoryAccount({ keypair: {} })
        } catch (e) {
          e.message.should.be.equal('KeyPair must must have "secretKey", "publicKey" properties')
        }
      })
      it('Fail on invalid secret key', async () => {
        try {
          MemoryAccount({
            keypair: {
              publicKey: testAcc.publicKey,
              secretKey: ' '
            }
          })
        } catch (e) {
          e.message.should.be.equal('Secret key must be hex string or Buffer')
        }
      })
      it('Fail on invalid publicKey', async () => {
        try {
          MemoryAccount({
            keypair: {
              publicKey: ' ',
              secretKey: testAcc.secretKey
            }
          })
        } catch (e) {
          e.message.should.be.equal('Public Key must be a base58c string with "ak_" prefix')
        }
      })
      it('Fail on invalid publicKey', async () => {
        try {
          MemoryAccount({
            keypair: {
              publicKey: generateKeyPair().publicKey,
              secretKey: testAcc.secretKey
            }
          })
        } catch (e) {
          e.message.should.be.equal('Invalid Key Pair')
        }
      })
    })
    it('Init with secretKey as hex string', async () => {
      const acc = MemoryAccount({
        keypair: {
          publicKey: testAcc.publicKey,
          secretKey: testAcc.secretKey
        }
      })
      return acc.address().should.eventually.be.equal(testAcc.publicKey)
    })
    it('Init with secretKey as hex Buffer', async () => {
      const acc = MemoryAccount({
        keypair: {
          publicKey: testAcc.publicKey,
          secretKey: Buffer.from(testAcc.secretKey, 'hex')
        }
      })
      return acc.address().should.eventually.be.equal(testAcc.publicKey)
    })
  })
  