mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-25 21:17:16 +00:00
44bbe97a1f
* save progress of db migration * save progress of db migration * delete * delete * delete * delete * delete * print full key if it has 8 leading zeroes * print full key if it has 8 leading zeroes * print full key if it has 8 leading zeroes
36 lines
949 B
Go
36 lines
949 B
Go
package migrations
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"testing"
|
|
|
|
"github.com/ledgerwatch/turbo-geth/common/dbutils"
|
|
"github.com/ledgerwatch/turbo-geth/ethdb"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestReceiptCbor(t *testing.T) {
|
|
require, db := require.New(t), ethdb.NewMemDatabase()
|
|
|
|
err := db.KV().Update(context.Background(), func(tx ethdb.Tx) error {
|
|
return tx.(ethdb.BucketMigrator).CreateBucket(dbutils.BlockReceiptsPrefix)
|
|
})
|
|
require.NoError(err)
|
|
|
|
migrator := NewMigrator()
|
|
migrator.Migrations = []Migration{receiptsCborEncode}
|
|
err = migrator.Apply(db, "")
|
|
require.NoError(err)
|
|
|
|
err = receiptsCborEncode.Up(db, "tmp-test-dir", nil, func(db ethdb.Putter, key []byte, isDone bool) error {
|
|
return nil
|
|
})
|
|
require.NoError(err)
|
|
|
|
err = receiptsCborEncode.Up(db, "tmp-test-dir", []byte("load"), func(db ethdb.Putter, key []byte, isDone bool) error {
|
|
return nil
|
|
})
|
|
require.True(errors.Is(err, ErrMigrationETLFilesDeleted))
|
|
}
|