import { ChannelId } from "@node-lightning/core" ; import { expect } from "chai" ; import { ShutdownMessage } from "../../lib/messages/ShutdownMessage" ; describe ( "ShutdownChannelMessage" , ( ) => { describe ( ".deserialize" , ( ) => { it ( "should deserialize without error" , ( ) => { const input = Buffer . from ( "0026" + "0000000000000000000000000000000000000000000000000000000000000000" + "0015" + "00a41a8527eab06efc0a8df57045d247784a071e23" , "hex" ) ; const result = ShutdownMessage . deserialize ( input ) ; expect ( result . type ) . to . equal ( 38 ) ; expect ( result . channelId . toString ( ) ) . to . equal ( "0000000000000000000000000000000000000000000000000000000000000000" ) ; expect ( result . scriptPubKey . toString ( "hex" ) ) . to . equal ( "00a41a8527eab06efc0a8df57045d247784a071e23" ) ; } ) ; } ) ; describe ( ".serialize" , ( ) => { it ( "should serialize a message" , ( ) => { const instance = new ShutdownMessage ( ) ; instance . channelId = new ChannelId ( Buffer . from ( "0000000000000000000000000000000000000000000000000000000000000000" , "hex" ) ) ; instance . scriptPubKey = Buffer . from ( "00a41a8527eab06efc0a8df57045d247784a071e23" , "hex" ) ; const result = instance . serialize ( ) ; expect ( result . toString ( "hex" ) ) . to . equal ( "0026" + "0000000000000000000000000000000000000000000000000000000000000000" + "0015" + "00a41a8527eab06efc0a8df57045d247784a071e23" ) ; } ) ; } ) ; } ) ;