@@ -29,13 +29,16 @@ import (
2929 . "github.com/ava-labs/libevm/core/types"
3030 "github.com/ava-labs/libevm/crypto"
3131 "github.com/ava-labs/libevm/libevm/ethtest"
32+ "github.com/ava-labs/libevm/libevm/pseudo"
3233 "github.com/ava-labs/libevm/rlp"
3334)
3435
3536type stubHeaderHooks struct {
3637 suffix []byte
3738 gotRawJSONToUnmarshal , gotRawRLPToDecode []byte
3839 setHeaderToOnUnmarshalOrDecode Header
40+ accessor pseudo.Accessor [* Header , * stubHeaderHooks ]
41+ copied * stubHeaderHooks
3942
4043 errMarshal , errUnmarshal , errEncode , errDecode error
4144}
@@ -75,7 +78,9 @@ func (hh *stubHeaderHooks) DecodeRLP(h *Header, s *rlp.Stream) error {
7578 return hh .errDecode
7679}
7780
78- func (hh * stubHeaderHooks ) PostCopy (dst * Header ) {}
81+ func (hh * stubHeaderHooks ) PostCopy (dst * Header ) {
82+ hh .accessor .Set (dst , hh .copied )
83+ }
7984
8085func TestHeaderHooks (t * testing.T ) {
8186 TestOnlyClearRegisteredExtras ()
@@ -137,6 +142,22 @@ func TestHeaderHooks(t *testing.T) {
137142 assert .Equalf (t , & stub .setHeaderToOnUnmarshalOrDecode , hdr , "%T after RLP decoding with hook" , hdr )
138143 })
139144
145+ t .Run ("PostCopy" , func (t * testing.T ) {
146+ hdr := new (Header )
147+ stub := & stubHeaderHooks {
148+ accessor : extras .Header ,
149+ copied : & stubHeaderHooks {
150+ suffix : []byte ("copied" ),
151+ },
152+ }
153+ extras .Header .Set (hdr , stub )
154+ cpy := CopyHeader (hdr )
155+
156+ copiedStub := extras .Header .Get (cpy )
157+
158+ assert .Equal (t , stub .copied , copiedStub )
159+ })
160+
140161 t .Run ("error_propagation" , func (t * testing.T ) {
141162 errMarshal := errors .New ("whoops" )
142163 errUnmarshal := errors .New ("is it broken?" )
0 commit comments