github.com/MetalBlockchain/metalgo@v1.11.9/chains/atomic/shared_memory_test.go (about)

     1  // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved.
     2  // See the file LICENSE for licensing terms.
     3  
     4  package atomic
     5  
     6  import (
     7  	"testing"
     8  
     9  	"github.com/MetalBlockchain/metalgo/database/memdb"
    10  	"github.com/MetalBlockchain/metalgo/database/prefixdb"
    11  	"github.com/MetalBlockchain/metalgo/ids"
    12  )
    13  
    14  func TestSharedMemory(t *testing.T) {
    15  	chainID0 := ids.GenerateTestID()
    16  	chainID1 := ids.GenerateTestID()
    17  
    18  	for _, test := range SharedMemoryTests {
    19  		baseDB := memdb.New()
    20  
    21  		memoryDB := prefixdb.New([]byte{0}, baseDB)
    22  		testDB := prefixdb.New([]byte{1}, baseDB)
    23  
    24  		m := NewMemory(memoryDB)
    25  
    26  		sm0 := m.NewSharedMemory(chainID0)
    27  		sm1 := m.NewSharedMemory(chainID1)
    28  
    29  		test(t, chainID0, chainID1, sm0, sm1, testDB)
    30  	}
    31  }