github.com/decred/dcrlnd@v0.7.6/channeldb/dcrmigrations/migration01/dcrmigration01_test.go (about) 1 package dcrmigration01 2 3 import ( 4 "testing" 5 6 "github.com/decred/dcrlnd/channeldb/migtest" 7 "github.com/decred/dcrlnd/kvdb" 8 ) 9 10 var ( 11 hexStr = migtest.Hex 12 13 tlvOutpointOpen = hexStr("000100") 14 tlvOutpointClosed = hexStr("000101") 15 16 outpointMig20 = hexStr("81b637d8fcd2c6da6859e6963113a1170de793e4b725b84d1e0b4cf99ec58ce952d6c6c7") 17 outpointMig20_2 = hexStr("abb637d8fcd2c6da6859e6963113a1170de793e4b725b84d1e0b4cf99ec58ce952d6c6c7") 18 outpointDataMig20 = map[string]interface{}{ 19 outpointMig20: tlvOutpointOpen, 20 outpointMig20_2: tlvOutpointClosed, 21 } 22 23 outpointCorrect = hexStr("81b637d8fcd2c6da6859e6963113a1170de793e4b725b84d1e0b4cf99ec58ce952d6c6c700") 24 outpointCorrect_2 = hexStr("abb637d8fcd2c6da6859e6963113a1170de793e4b725b84d1e0b4cf99ec58ce952d6c6c700") 25 outpointDataCorrect = map[string]interface{}{ 26 outpointCorrect: tlvOutpointOpen, 27 outpointCorrect_2: tlvOutpointClosed, 28 } 29 ) 30 31 func TestFixMigration20(t *testing.T) { 32 // Prime the database with the results of migration20 (wrong outpoint 33 // key). 34 before := func(tx kvdb.RwTx) error { 35 return migtest.RestoreDB(tx, outpointBucket, outpointDataMig20) 36 } 37 38 // Double check the keys were migrated to use the correct serialization 39 // of outpoint. 40 after := func(tx kvdb.RwTx) error { 41 return migtest.VerifyDB(tx, outpointBucket, outpointDataCorrect) 42 } 43 44 migtest.ApplyMigration(t, before, after, FixMigration20, false) 45 }