it('Serialize path through XRP IOUs', function() {
      var hex = '31000000000000000000000000000000000000007B00000000000000000000000055534400000000000000000000000000000000000000000000000315FF1000000000000000000000000058525000000000003100000000000000000000000000000000000003DB0000000000000000000000004555520000000000000000000000000000000000000000000000014100';
      var json = [
        [{
          account: 'rrrrrrrrrrrrrrrrrrrrNxV3Xza',
          currency: 'USD',
          issuer: 'rrrrrrrrrrrrrrrrrrrpYnYCNYf'
        }],
        [{
          currency: 'XRP',
          non_native: true
        }, {
          account: 'rrrrrrrrrrrrrrrrrrrpvQsW3V3',
          currency: 'EUR',
          issuer: 'rrrrrrrrrrrrrrrrrrrdHRtqg2'
        }]
      ];

      var result_json = [
        [{
          account: 'rrrrrrrrrrrrrrrrrrrrNxV3Xza',
          currency: 'USD',
          issuer: 'rrrrrrrrrrrrrrrrrrrpYnYCNYf',
          type: 49,
          type_hex: '0000000000000031'
        }],
        [{
          currency: 'XRP',
          non_native: true,
          type: 16,
          type_hex: '0000000000000010'
        }, {
          account: 'rrrrrrrrrrrrrrrrrrrpvQsW3V3',
          currency: 'EUR',
          issuer: 'rrrrrrrrrrrrrrrrrrrdHRtqg2',
          type: 49,
          type_hex: '0000000000000031'
        }]
      ];

      var so = new SerializedObject();
      types.PathSet.serialize(so, json);
      assert.strictEqual(so.to_hex(), hex);

      so = new SerializedObject(hex);
      var parsed_path = SerializedObject.jsonify_structure(types.PathSet.parse(so));
      assert.deepEqual(parsed_path, result_json);
    });
    it('Parse [[e],[e,e]]', function() {
      var so = new SerializedObject('31000000000000000000000000000000000000007B00000000000000000000000055534400000000000000000000000000000000000000000000000315FF31000000000000000000000000000000000000007B000000000000000000000000425443000000000000000000000000000000000000000000000003153100000000000000000000000000000000000003DB0000000000000000000000004555520000000000000000000000000000000000000000000000014100');

      var parsed_path = types.PathSet.parse(so);
      var comp = [
        [
          {
            account: 'rrrrrrrrrrrrrrrrrrrrNxV3Xza',
            currency: 'USD',
            issuer: 'rrrrrrrrrrrrrrrrrrrpYnYCNYf',
            type: 49,
            type_hex: '0000000000000031'
          }
        ],
        [
          {
            account: 'rrrrrrrrrrrrrrrrrrrrNxV3Xza',
            currency: 'BTC',
            issuer: 'rrrrrrrrrrrrrrrrrrrpYnYCNYf',
            type: 49,
            type_hex: '0000000000000031'
          },
          {
            account: 'rrrrrrrrrrrrrrrrrrrpvQsW3V3',
            currency: 'EUR',
            issuer: 'rrrrrrrrrrrrrrrrrrrdHRtqg2',
            type: 49,
            type_hex: '0000000000000031'
          }
        ]
      ];

      assert.deepEqual(SerializedObject.jsonify_structure(parsed_path, ''), comp);
    });
 it('Serialize [[e],[e,e]]', function() {
   var so = new SerializedObject();
   types.PathSet.serialize(so, [[{
     account: 123,
     currency: 'USD',
     issuer: 789
   }],
   [{
     account: 123,
     currency: 'BTC',
     issuer: 789
   },
   {
     account: 987,
     currency: 'EUR',
     issuer: 321
   }]]);
   assert.strictEqual(so.to_hex(), '31000000000000000000000000000000000000007B00000000000000000000000055534400000000000000000000000000000000000000000000000315FF31000000000000000000000000000000000000007B000000000000000000000000425443000000000000000000000000000000000000000000000003153100000000000000000000000000000000000003DB0000000000000000000000004555520000000000000000000000000000000000000000000000014100'); // TODO: Check this independently
 });
 it('Parse single empty path [[]]', function() {
   var so = new SerializedObject('00');
   var parsed_path = SerializedObject.jsonify_structure(types.PathSet.parse(so));
   assert.deepEqual(parsed_path, [[]]);
 });
    it('Serialize path through XRP IOUs (realistic example)', function() {
      // Appears in the history
      // TX #0CBB429C456ED999CC691DFCC8E62E8C8C7E9522C2BEA967FED0D7E2A9B28D13
      // Note that XRP IOUs are no longer allowed, so this functionality is
      // for historic transactions only.

      var hex = '31585E1F3BD02A15D6185F8BB9B57CC60DEDDB37C10000000000000000000000004254430000000000585E1F3BD02A15D6185F8BB9B57CC60DEDDB37C131E4FE687C90257D3D2D694C8531CDEECBE84F33670000000000000000000000004254430000000000E4FE687C90257D3D2D694C8531CDEECBE84F3367310A20B3C85F482532A9578DBB3950B85CA06594D100000000000000000000000042544300000000000A20B3C85F482532A9578DBB3950B85CA06594D13000000000000000000000000055534400000000000A20B3C85F482532A9578DBB3950B85CA06594D1FF31585E1F3BD02A15D6185F8BB9B57CC60DEDDB37C10000000000000000000000004254430000000000585E1F3BD02A15D6185F8BB9B57CC60DEDDB37C131E4FE687C90257D3D2D694C8531CDEECBE84F33670000000000000000000000004254430000000000E4FE687C90257D3D2D694C8531CDEECBE84F33673115036E2D3F5437A83E5AC3CAEE34FF2C21DEB618000000000000000000000000425443000000000015036E2D3F5437A83E5AC3CAEE34FF2C21DEB6183000000000000000000000000055534400000000000A20B3C85F482532A9578DBB3950B85CA06594D1FF31585E1F3BD02A15D6185F8BB9B57CC60DEDDB37C10000000000000000000000004254430000000000585E1F3BD02A15D6185F8BB9B57CC60DEDDB37C13157180C769B66D942EE69E6DCC940CA48D82337AD000000000000000000000000425443000000000057180C769B66D942EE69E6DCC940CA48D82337AD1000000000000000000000000058525000000000003000000000000000000000000055534400000000000A20B3C85F482532A9578DBB3950B85CA06594D100';
      var json = [
        [{
          account: 'r9hEDb4xBGRfBCcX3E4FirDWQBAYtpxC8K',
          currency: 'BTC',
          issuer: 'r9hEDb4xBGRfBCcX3E4FirDWQBAYtpxC8K'
        }, {
          account: 'rM1oqKtfh1zgjdAgbFmaRm3btfGBX25xVo',
          currency: 'BTC',
          issuer: 'rM1oqKtfh1zgjdAgbFmaRm3btfGBX25xVo'
        }, {
          account: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B',
          currency: 'BTC',
          issuer: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B'
        }, {
          currency: 'USD',
          issuer: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B'
        }],
        [{
          account: 'r9hEDb4xBGRfBCcX3E4FirDWQBAYtpxC8K',
          currency: 'BTC',
          issuer: 'r9hEDb4xBGRfBCcX3E4FirDWQBAYtpxC8K'
        }, {
          account: 'rM1oqKtfh1zgjdAgbFmaRm3btfGBX25xVo',
          currency: 'BTC',
          issuer: 'rM1oqKtfh1zgjdAgbFmaRm3btfGBX25xVo'
        }, {
          account: 'rpvfJ4mR6QQAeogpXEKnuyGBx8mYCSnYZi',
          currency: 'BTC',
          issuer: 'rpvfJ4mR6QQAeogpXEKnuyGBx8mYCSnYZi'
        }, {
          currency: 'USD',
          issuer: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B'
        }],
        [{
          account: 'r9hEDb4xBGRfBCcX3E4FirDWQBAYtpxC8K',
          currency: 'BTC',
          issuer: 'r9hEDb4xBGRfBCcX3E4FirDWQBAYtpxC8K'
        }, {
          account: 'r3AWbdp2jQLXLywJypdoNwVSvr81xs3uhn',
          currency: 'BTC',
          issuer: 'r3AWbdp2jQLXLywJypdoNwVSvr81xs3uhn'
        }, {
          currency: 'XRP',
          non_native: true
        }, {
          currency: 'USD',
          issuer: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B'
        }]
      ];

      var result_json = [
        [{
          account: 'r9hEDb4xBGRfBCcX3E4FirDWQBAYtpxC8K',
          currency: 'BTC',
          issuer: 'r9hEDb4xBGRfBCcX3E4FirDWQBAYtpxC8K',
          type: 49,
          type_hex: '0000000000000031'
        }, {
          account: 'rM1oqKtfh1zgjdAgbFmaRm3btfGBX25xVo',
          currency: 'BTC',
          issuer: 'rM1oqKtfh1zgjdAgbFmaRm3btfGBX25xVo',
          type: 49,
          type_hex: '0000000000000031'
        }, {
          account: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B',
          currency: 'BTC',
          issuer: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B',
          type: 49,
          type_hex: '0000000000000031'
        }, {
          currency: 'USD',
          issuer: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B',
          type: 48,
          type_hex: '0000000000000030'
        }],
        [{
          account: 'r9hEDb4xBGRfBCcX3E4FirDWQBAYtpxC8K',
          currency: 'BTC',
          issuer: 'r9hEDb4xBGRfBCcX3E4FirDWQBAYtpxC8K',
          type: 49,
          type_hex: '0000000000000031'
        }, {
          account: 'rM1oqKtfh1zgjdAgbFmaRm3btfGBX25xVo',
          currency: 'BTC',
          issuer: 'rM1oqKtfh1zgjdAgbFmaRm3btfGBX25xVo',
          type: 49,
          type_hex: '0000000000000031'
        }, {
          account: 'rpvfJ4mR6QQAeogpXEKnuyGBx8mYCSnYZi',
          currency: 'BTC',
          issuer: 'rpvfJ4mR6QQAeogpXEKnuyGBx8mYCSnYZi',
          type: 49,
          type_hex: '0000000000000031'
        }, {
          currency: 'USD',
          issuer: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B',
          type: 48,
          type_hex: '0000000000000030'
        }],
        [{
          account: 'r9hEDb4xBGRfBCcX3E4FirDWQBAYtpxC8K',
          currency: 'BTC',
          issuer: 'r9hEDb4xBGRfBCcX3E4FirDWQBAYtpxC8K',
          type: 49,
          type_hex: '0000000000000031'
        }, {
          account: 'r3AWbdp2jQLXLywJypdoNwVSvr81xs3uhn',
          currency: 'BTC',
          issuer: 'r3AWbdp2jQLXLywJypdoNwVSvr81xs3uhn',
          type: 49,
          type_hex: '0000000000000031'
        }, {
          currency: 'XRP',
          non_native: true,
          type: 16,
          type_hex: '0000000000000010'
        }, {
          currency: 'USD',
          issuer: 'rvYAfWj5gh67oV6fW32ZzP3Aw4Eubs59B',
          type: 48,
          type_hex: '0000000000000030'
        }]
      ];

      var so = new SerializedObject();
      types.PathSet.serialize(so, json);
      assert.strictEqual(so.to_hex(), hex);

      so = new SerializedObject(hex);
      var parsed_path = SerializedObject.jsonify_structure(types.PathSet.parse(so));
      assert.deepEqual(parsed_path, result_json);
    });
 it('Serialize single empty path [[]]', function() {
   var so = new SerializedObject();
   types.PathSet.serialize(so, [[]]);
   assert.strictEqual(so.to_hex(), '00');
 });