"use strict";
exports.__esModule = true;
var samples_1 = require("@iota/samples");
var ava_1 = require("ava");
var src_1 = require("../src");
var invalidAddress = 'UYEEERFQYTPFAHIPXDQAQYWYMSMCLMGBTYAXLWFRFFWPYFOICOVLK9A9VYNCKK9TQUNBTARCEQXJHD';
ava_1["default"]('addChecksum() adds 9-trytes checksum', function (t) {
    t.is(src_1.addChecksum(samples_1.address), samples_1.addressWithChecksum, 'addChecksum() should add 9-trytes checksum to the end of address.');
});
ava_1["default"]('addChecksum() returns the exact address, if was passed with checksum', function (t) {
    t.is(src_1.addChecksum(samples_1.addressWithChecksum), samples_1.addressWithChecksum, 'addChecksum() should return the exact address, if was passed with checksum.');
});
ava_1["default"]('addChecksum() throws error for invalid addresses', function (t) {
    var error = t.throws(function () { return src_1.addChecksum(invalidAddress); }, Error, 'addChecksum() should throw error if address is invalid.');
    t.is(error.message, src_1.errors.INVALID_ADDRESS, 'addChecksum() should throw correct error message.');
});
ava_1["default"]('addChecksum() adds checksum of arbitrary length', function (t) {
    var trytes = '9'.repeat(81);
    var trytesWithChecksum = trytes + 'KZW';
    t.is(src_1.addChecksum(trytes, 3, false), trytesWithChecksum, 'addChecsum() should add checksum of arbitrary length.');
});
ava_1["default"]('isValidChecksum() correctly validates the checksum', function (t) {
    t.is(src_1.isValidChecksum(samples_1.addressWithInvalidChecksum), false, 'isValidChecksum() should return false for address with invalid checksum.');
    t.is(src_1.isValidChecksum(samples_1.address), false, 'isValidChecksum() should return false for address without checksum.');
});
ava_1["default"]('isValidChecksum() throws error for invalid address', function (t) {
    var error = t.throws(function () { return src_1.isValidChecksum(invalidAddress); }, Error, 'isValidChecksum() should throw error if invalid address was passed.');
    t.is(error.message, src_1.errors.INVALID_ADDRESS, 'isValidChecksum() should throw correct error message.');
});
ava_1["default"]('removeChecksum() removes checksum from addresses with checksum', function (t) {
    t.deepEqual(src_1.removeChecksum(samples_1.addressWithChecksum), samples_1.address, 'removeChecksum() should remove checksum from address with checksum.');
});
ava_1["default"]('removeChecksum() returns the exact address, if was passed without checksum', function (t) {
    t.deepEqual(src_1.removeChecksum(samples_1.address), samples_1.address, 'removeChecksum() should return the exact address if was passed without checksum.');
});
ava_1["default"]('removeChecksum() throws error for invalid addresses', function (t) {
    var error = t.throws(function () { return src_1.removeChecksum(invalidAddress); }, Error, 'removeChecksum() should throw error if invalid address was passed.');
    t.is(error.message, src_1.errors.INVALID_ADDRESS, 'removeChecksum() should throw correct error message.');
});
//# sourceMappingURL=checksum.test.js.map