(t *testing.T)
| 37 | ) |
| 38 | |
| 39 | func TestMetaState(t *testing.T) { |
| 40 | Convey("Given a new metaState object and a persistence db instance", t, func() { |
| 41 | var ( |
| 42 | ao *types.Account |
| 43 | co *types.SQLChainProfile |
| 44 | po *types.ProviderProfile |
| 45 | bl uint64 |
| 46 | loaded bool |
| 47 | err error |
| 48 | privKey1 *asymmetric.PrivateKey |
| 49 | privKey2 *asymmetric.PrivateKey |
| 50 | privKey3 *asymmetric.PrivateKey |
| 51 | privKey4 *asymmetric.PrivateKey |
| 52 | addr1 proto.AccountAddress |
| 53 | addr2 proto.AccountAddress |
| 54 | addr3 proto.AccountAddress |
| 55 | addr4 proto.AccountAddress |
| 56 | dbID1 = proto.DatabaseID("db#1") |
| 57 | dbID2 = proto.DatabaseID("db#2") |
| 58 | dbID3 = proto.DatabaseID("db#3") |
| 59 | ms = newMetaState() |
| 60 | ) |
| 61 | So(err, ShouldBeNil) |
| 62 | |
| 63 | // Create key pairs and addresses for test |
| 64 | privKey1, _, err = asymmetric.GenSecp256k1KeyPair() |
| 65 | So(err, ShouldBeNil) |
| 66 | privKey2, _, err = asymmetric.GenSecp256k1KeyPair() |
| 67 | So(err, ShouldBeNil) |
| 68 | privKey3, _, err = asymmetric.GenSecp256k1KeyPair() |
| 69 | So(err, ShouldBeNil) |
| 70 | privKey4, _, err = asymmetric.GenSecp256k1KeyPair() |
| 71 | So(err, ShouldBeNil) |
| 72 | addr1, err = crypto.PubKeyHash(privKey1.PubKey()) |
| 73 | So(err, ShouldBeNil) |
| 74 | addr2, err = crypto.PubKeyHash(privKey2.PubKey()) |
| 75 | So(err, ShouldBeNil) |
| 76 | addr3, err = crypto.PubKeyHash(privKey3.PubKey()) |
| 77 | So(err, ShouldBeNil) |
| 78 | addr4, err = crypto.PubKeyHash(privKey4.PubKey()) |
| 79 | So(err, ShouldBeNil) |
| 80 | |
| 81 | Convey("The account state should be empty", func() { |
| 82 | ao, loaded = ms.loadAccountObject(addr1) |
| 83 | So(ao, ShouldBeNil) |
| 84 | So(loaded, ShouldBeFalse) |
| 85 | bl, loaded = ms.loadAccountTokenBalance(addr1, types.Particle) |
| 86 | So(loaded, ShouldBeFalse) |
| 87 | bl, loaded = ms.loadAccountTokenBalance(addr1, types.Wave) |
| 88 | So(loaded, ShouldBeFalse) |
| 89 | }) |
| 90 | Convey("The database state should be empty", func() { |
| 91 | co, loaded = ms.loadSQLChainObject(dbID1) |
| 92 | So(co, ShouldBeNil) |
| 93 | So(loaded, ShouldBeFalse) |
| 94 | }) |
| 95 | Convey("The provider state should be empty", func() { |
| 96 | po, loaded = ms.loadProviderObject(addr1) |
nothing calls this directly
no test coverage detected