-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathbalance_check.go
More file actions
52 lines (41 loc) · 863 Bytes
/
balance_check.go
File metadata and controls
52 lines (41 loc) · 863 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package mscd
import (
"github.com/mastercoin-MSC/mscutil"
"fmt"
"encoding/json"
"os"
)
type Balance struct {
Real uint64
Test uint64
}
type Sheet struct {
Hash string
Data Balance
}
func TestBalances(db *mscutil.LDBDatabase) bool {
file, err := os.Open("/home/dev/compare.json")
if err != nil {
fmt.Println("FILE:", err)
os.Exit(1)
}
fileInfo, _ := file.Stat()
jsonBlob := make([]byte, fileInfo.Size())
file.Read(jsonBlob)
var sheets []Sheet
err = json.Unmarshal(jsonBlob, &sheets)
if err != nil {
fmt.Println("JSON:", err)
os.Exit(1)
}
failed := 0
for _, sheet := range sheets {
acc := db.GetAccount(sheet.Hash)
if sheet.Data.Real != acc[1] {
fmt.Printf("Failed cmp for %s %d != %d\n", sheet.Hash, sheet.Data.Real, acc[1])
failed++
}
}
fmt.Printf("Failed %d (len = %d)\n", failed, len(sheets))
return true
}