-
Notifications
You must be signed in to change notification settings - Fork 0
/
state_test.go
51 lines (49 loc) · 1.03 KB
/
state_test.go
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
package main
import (
"cryptocurrency/node_util"
"github.com/stretchr/testify/assert"
"testing"
)
func TestTransitionState(t *testing.T) {
t.Run("It correctly transitions the state", func(t *testing.T) {
// Arrange
state := node_util.State{
Data: map[string][]byte{
"123": []byte("321"),
},
Contracts: map[uint64]node_util.Contract{
0: {
Contents: "",
Parties: nil,
GasUsed: 0,
Location: 0,
Loaded: false,
},
},
}
transition := node_util.StateTransition{
UpdatedData: map[string][]byte{
"321": []byte("123"),
},
NewContracts: map[uint64]node_util.Contract{
1: {
Contents: "",
Parties: nil,
GasUsed: 0,
Location: 0,
Loaded: false,
},
},
}
// Act
newState := node_util.TransitionState(state, transition)
// Assert
for key, value := range transition.UpdatedData {
state.Data[key] = value
}
for key, value := range transition.NewContracts {
state.Contracts[key] = value
}
assert.Equal(t, state, newState)
})
}