@@ -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+ toCopy * stubHeaderHooks
3942
4043 errMarshal , errUnmarshal , errEncode , errDecode error
4144}
@@ -75,6 +78,10 @@ func (hh *stubHeaderHooks) DecodeRLP(h *Header, s *rlp.Stream) error {
7578 return hh .errDecode
7679}
7780
81+ func (hh * stubHeaderHooks ) PostCopy (dst * Header ) {
82+ hh .accessor .Set (dst , hh .toCopy )
83+ }
84+
7885func TestHeaderHooks (t * testing.T ) {
7986 TestOnlyClearRegisteredExtras ()
8087 defer TestOnlyClearRegisteredExtras ()
@@ -135,6 +142,20 @@ func TestHeaderHooks(t *testing.T) {
135142 assert .Equalf (t , & stub .setHeaderToOnUnmarshalOrDecode , hdr , "%T after RLP decoding with hook" , hdr )
136143 })
137144
145+ t .Run ("PostCopy" , func (t * testing.T ) {
146+ hdr := new (Header )
147+ stub := & stubHeaderHooks {
148+ accessor : extras .Header ,
149+ toCopy : & stubHeaderHooks {
150+ suffix : []byte ("copied" ),
151+ },
152+ }
153+ extras .Header .Set (hdr , stub )
154+
155+ got := extras .Header .Get (CopyHeader (hdr ))
156+ assert .Equal (t , stub .toCopy , got )
157+ })
158+
138159 t .Run ("error_propagation" , func (t * testing.T ) {
139160 errMarshal := errors .New ("whoops" )
140161 errUnmarshal := errors .New ("is it broken?" )
0 commit comments