def test_encode_decode_msg__init(self):
    self.assertEqual(bfh('00100000000220c2'), encode_msg('init', gflen=0, flen=2, features=(((LnFeatures.OPTION_STATIC_REMOTEKEY_OPT | LnFeatures.GOSSIP_QUERIES_OPT) | LnFeatures.GOSSIP_QUERIES_REQ) | LnFeatures.OPTION_DATA_LOSS_PROTECT_OPT)))
    self.assertEqual(bfh('00100000000220c2'), encode_msg('init', gflen=0, flen=2, features=bfh('20c2')))
    self.assertEqual(bfh('00100000000220c2012043497fd7f826957108f4a30fd9cec3aeba79972084e90ead01ea330900000000'), encode_msg('init', gflen=0, flen=2, features=(((LnFeatures.OPTION_STATIC_REMOTEKEY_OPT | LnFeatures.GOSSIP_QUERIES_OPT) | LnFeatures.GOSSIP_QUERIES_REQ) | LnFeatures.OPTION_DATA_LOSS_PROTECT_OPT), init_tlvs={'networks': {'chains': b'CI\x7f\xd7\xf8&\x95q\x08\xf4\xa3\x0f\xd9\xce\xc3\xae\xbay\x97 \x84\xe9\x0e\xad\x01\xea3\t\x00\x00\x00\x00'}}))
    self.assertEqual(('init', {'gflen': 2, 'globalfeatures': b'"\x00', 'flen': 3, 'features': b'\x02\xa2\xa1', 'init_tlvs': {}}), decode_msg(bfh('001000022200000302a2a1')))
    self.assertEqual(('init', {'gflen': 2, 'globalfeatures': b'"\x00', 'flen': 3, 'features': b'\x02\xaa\xa2', 'init_tlvs': {'networks': {'chains': b'CI\x7f\xd7\xf8&\x95q\x08\xf4\xa3\x0f\xd9\xce\xc3\xae\xbay\x97 \x84\xe9\x0e\xad\x01\xea3\t\x00\x00\x00\x00'}}}), decode_msg(bfh('001000022200000302aaa2012043497fd7f826957108f4a30fd9cec3aeba79972084e90ead01ea330900000000')))
def test_encode_decode_msg__init(self):
    self.assertEqual(bfh('00100000000220c2'), encode_msg('init', gflen=0, flen=2, features=(((LnFeatures.OPTION_STATIC_REMOTEKEY_OPT | LnFeatures.GOSSIP_QUERIES_OPT) | LnFeatures.GOSSIP_QUERIES_REQ) | LnFeatures.OPTION_DATA_LOSS_PROTECT_OPT)))
    self.assertEqual(bfh('00100000000220c2'), encode_msg('init', gflen=0, flen=2, features=bfh('20c2')))
    self.assertEqual(bfh('00100000000220c2012043497fd7f826957108f4a30fd9cec3aeba79972084e90ead01ea330900000000'), encode_msg('init', gflen=0, flen=2, features=(((LnFeatures.OPTION_STATIC_REMOTEKEY_OPT | LnFeatures.GOSSIP_QUERIES_OPT) | LnFeatures.GOSSIP_QUERIES_REQ) | LnFeatures.OPTION_DATA_LOSS_PROTECT_OPT), init_tlvs={'networks': {'chains': b'CI\x7f\xd7\xf8&\x95q\x08\xf4\xa3\x0f\xd9\xce\xc3\xae\xbay\x97 \x84\xe9\x0e\xad\x01\xea3\t\x00\x00\x00\x00'}}))
    self.assertEqual(('init', {'gflen': 2, 'globalfeatures': b'"\x00', 'flen': 3, 'features': b'\x02\xa2\xa1', 'init_tlvs': {}}), decode_msg(bfh('001000022200000302a2a1')))
    self.assertEqual(('init', {'gflen': 2, 'globalfeatures': b'"\x00', 'flen': 3, 'features': b'\x02\xaa\xa2', 'init_tlvs': {'networks': {'chains': b'CI\x7f\xd7\xf8&\x95q\x08\xf4\xa3\x0f\xd9\xce\xc3\xae\xbay\x97 \x84\xe9\x0e\xad\x01\xea3\t\x00\x00\x00\x00'}}}), decode_msg(bfh('001000022200000302aaa2012043497fd7f826957108f4a30fd9cec3aeba79972084e90ead01ea330900000000')))