@@ -163,7 +163,7 @@ describe('OP_RETURN', function () {
163163 ) ;
164164 } ) ;
165165
166- it ( 'should have the correct placement of the values provided with a timelock' , function ( ) {
166+ it ( 'should have the correct placement of the values provided with a blockheight timelock' , function ( ) {
167167 // This should produce an Op_RETURN that needs the extra push bytes for the length
168168 const script = createCoreDaoOpReturnOutputScript ( {
169169 version : validVersion ,
@@ -198,6 +198,42 @@ describe('OP_RETURN', function () {
198198 assert . deepStrictEqual ( decodeTimelock ( script . subarray ( 50 , 54 ) ) , validTimelock ) ;
199199 } ) ;
200200
201+ it ( 'should have the correct placement of the values provided with a time timelock' , function ( ) {
202+ // This should produce an Op_RETURN that needs the extra push bytes for the length
203+ const timelock = new Date ( '2022-01-01T00:00:00Z' ) . getTime ( ) / 1000 ;
204+ const script = createCoreDaoOpReturnOutputScript ( {
205+ version : validVersion ,
206+ chainId : validChainId ,
207+ delegator : validDelegator ,
208+ validator : validValidator ,
209+ fee : validFee ,
210+ timelock,
211+ } ) ;
212+ // Make sure that the first byte is the OP_RETURN opcode
213+ assert . strictEqual ( script [ 0 ] , 0x6a ) ;
214+ // Make sure that the length of the script matches what is in the buffer
215+ assert . strictEqual (
216+ // We do not count the OP_RETURN opcode or the length
217+ script . length - 2 ,
218+ script [ 1 ]
219+ ) ;
220+ // Satoshi plus identifier
221+ assert . deepStrictEqual ( script . subarray ( 2 , 6 ) . toString ( 'hex' ) , CORE_DAO_SATOSHI_PLUS_IDENTIFIER . toString ( 'hex' ) ) ;
222+ // Make sure that the version is correct
223+ assert . strictEqual ( script [ 6 ] , validVersion ) ;
224+ // Make sure that the chainId is correct
225+ assert . deepStrictEqual ( script . subarray ( 7 , 9 ) . toString ( 'hex' ) , validChainId . toString ( 'hex' ) ) ;
226+ // Make sure that the delegator is correct
227+ assert . deepStrictEqual ( script . subarray ( 9 , 29 ) . toString ( 'hex' ) , validDelegator . toString ( 'hex' ) ) ;
228+ // Make sure that the validator is correct
229+ assert . deepStrictEqual ( script . subarray ( 29 , 49 ) . toString ( 'hex' ) , validValidator . toString ( 'hex' ) ) ;
230+ // Make sure that the fee is correct
231+ assert . strictEqual ( script [ 49 ] , validFee ) ;
232+ // Make sure that the redeemScript is correct
233+ assert . deepStrictEqual ( script . subarray ( 50 , 54 ) . toString ( 'hex' ) , encodeTimelock ( timelock ) . toString ( 'hex' ) ) ;
234+ assert . deepStrictEqual ( decodeTimelock ( script . subarray ( 50 , 54 ) ) , timelock ) ;
235+ } ) ;
236+
201237 it ( 'should recreate the example OP_RETURN correctly' , function ( ) {
202238 assert . deepStrictEqual (
203239 createCoreDaoOpReturnOutputScript ( {
0 commit comments