data-items-cleanup #203
@ -63,7 +63,7 @@ func GetTransferData(ctx context.Context, db storage.PrefixDb, publicKey string,
 | 
			
		||||
	for _, key := range keys {
 | 
			
		||||
		value, err := db.Get(ctx, key.ToBytes())
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			return "", fmt.Errorf("failed to get %s: %v", key, err)
 | 
			
		||||
			return "", fmt.Errorf("failed to get %s: %v", key.ToBytes(), err)
 | 
			
		||||
		}
 | 
			
		||||
		data[key] = string(value)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -86,16 +86,16 @@ func TestGetVoucherData(t *testing.T) {
 | 
			
		||||
	spdb := storage.NewSubPrefixDb(db, []byte("vouchers"))
 | 
			
		||||
| 
					
	
	
	
	
	
	
	
	 
					
					Alfred-mk marked this conversation as resolved
					
				 
				 | 
			||||
 | 
			
		||||
	// Test voucher data
 | 
			
		||||
	mockData := map[string][]byte{
 | 
			
		||||
		"sym":  []byte("1:SRF\n2:MILO"),
 | 
			
		||||
		"bal":  []byte("1:100\n2:200"),
 | 
			
		||||
		"deci": []byte("1:6\n2:4"),
 | 
			
		||||
		"addr": []byte("1:0xd4c288865Ce\n2:0x41c188d63Qa"),
 | 
			
		||||
	mockData := map[DataTyp][]byte{
 | 
			
		||||
		DATA_PREFIX_SYMBOLS:   []byte("1:SRF\n2:MILO"),
 | 
			
		||||
		DATA_PREFIX_BALANCES:  []byte("1:100\n2:200"),
 | 
			
		||||
		DATA_PREFIX_DECIMALS:  []byte("1:6\n2:4"),
 | 
			
		||||
		DATA_PREFIX_ADDRESSES: []byte("1:0xd4c288865Ce\n2:0x41c188d63Qa"),
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Put the data
 | 
			
		||||
	for key, value := range mockData {
 | 
			
		||||
		err = spdb.Put(ctx, []byte(key), []byte(value))
 | 
			
		||||
		err = spdb.Put(ctx, []byte(key.ToBytes()), []byte(value))
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			t.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -1937,7 +1937,7 @@ func TestCheckVouchers(t *testing.T) {
 | 
			
		||||
	assert.NoError(t, err)
 | 
			
		||||
 | 
			
		||||
	// Read voucher sym data from the store
 | 
			
		||||
	voucherData, err := spdb.Get(ctx, []byte("sym"))
 | 
			
		||||
	voucherData, err := spdb.Get(ctx, common.DATA_PREFIX_SYMBOLS.ToBytes())
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		t.Fatal(err)
 | 
			
		||||
	}
 | 
			
		||||
@ -1961,7 +1961,7 @@ func TestGetVoucherList(t *testing.T) {
 | 
			
		||||
	expectedSym := []byte("1:SRF\n2:MILO")
 | 
			
		||||
 | 
			
		||||
	// Put voucher sym data from the store
 | 
			
		||||
	err := spdb.Put(ctx, []byte("sym"), expectedSym)
 | 
			
		||||
	err := spdb.Put(ctx, common.DATA_PREFIX_SYMBOLS.ToBytes(), expectedSym)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		t.Fatal(err)
 | 
			
		||||
	}
 | 
			
		||||
@ -1991,16 +1991,16 @@ func TestViewVoucher(t *testing.T) {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Define mock voucher data
 | 
			
		||||
	mockData := map[string][]byte{
 | 
			
		||||
		"sym":  []byte("1:SRF\n2:MILO"),
 | 
			
		||||
		"bal":  []byte("1:100\n2:200"),
 | 
			
		||||
		"deci": []byte("1:6\n2:4"),
 | 
			
		||||
		"addr": []byte("1:0xd4c288865Ce\n2:0x41c188d63Qa"),
 | 
			
		||||
	mockData := map[common.DataTyp][]byte{
 | 
			
		||||
		common.DATA_PREFIX_SYMBOLS:   []byte("1:SRF\n2:MILO"),
 | 
			
		||||
		common.DATA_PREFIX_BALANCES:  []byte("1:100\n2:200"),
 | 
			
		||||
		common.DATA_PREFIX_DECIMALS:  []byte("1:6\n2:4"),
 | 
			
		||||
		common.DATA_PREFIX_ADDRESSES: []byte("1:0xd4c288865Ce\n2:0x41c188d63Qa"),
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Put the data
 | 
			
		||||
	for key, value := range mockData {
 | 
			
		||||
		err = spdb.Put(ctx, []byte(key), []byte(value))
 | 
			
		||||
		err = spdb.Put(ctx, []byte(key.ToBytes()), []byte(value))
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			t.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	
The prefix should be
DATATYPE_USERDATA