Skip to content

Commit

Permalink
Merge branch 'main' into tla+-update
Browse files Browse the repository at this point in the history
  • Loading branch information
b00f committed Aug 21, 2023
2 parents 1d54885 + 5a08896 commit 1fb44c8
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 53 deletions.
3 changes: 0 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ linters:
- gochecknoinits
- dupl
- goconst
- errchkjson # Consider to enable it
- gocognit # Consider to enable it
- funlen # Consider to enable it
- forbidigo # Consider to enable it
Expand All @@ -38,7 +37,6 @@ linters:
- exhaustive # Consider to enable it
- exhaustruct # Consider to enable it
- forcetypeassert # Consider to enable it
- musttag # Consider to enable it (is i possible?)
- goerr113 # Consider to enable it
- errorlint # Consider to enable it
- errname # Consider to enable it
Expand All @@ -47,7 +45,6 @@ linters:
- nonamedreturns # Consider to enable it
- nlreturn # Consider to enable it
- ireturn # Consider to enable it (??)
- dupword # Consider to enable it

linters-settings:
gosimple:
Expand Down
14 changes: 7 additions & 7 deletions genesis/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ func (n ChainType) String() string {
}

type genAccount struct {
Address string `cbor:"1,keyasint"`
Balance int64 `cbor:"2,keyasint"`
Address string `cbor:"1,keyasint" json:"address"`
Balance int64 `cbor:"2,keyasint" json:"balance"`
}

type genValidator struct {
PublicKey string `cbor:"1,keyasint"`
PublicKey string `cbor:"1,keyasint" json:"public_key"`
}

// Genesis is stored in the state database.
Expand All @@ -56,10 +56,10 @@ type Genesis struct {
}

type genesisData struct {
GenesisTime time.Time `cbor:"1,keyasint"`
Params param.Params `cbor:"2,keyasint"`
Accounts []genAccount `cbor:"3,keyasint"`
Validators []genValidator `cbor:"4,keyasint"`
GenesisTime time.Time `cbor:"1,keyasint" json:"genesis_time"`
Params param.Params `cbor:"2,keyasint" json:"params"`
Accounts []genAccount `cbor:"3,keyasint" json:"accounts"`
Validators []genValidator `cbor:"4,keyasint" json:"validators"`
}

func (gen *Genesis) Hash() hash.Hash {
Expand Down
2 changes: 1 addition & 1 deletion genesis/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func TestGenesisTestNet(t *testing.T) {
genTime, _ := time.Parse("2006-01-02", "2023-05-08")
assert.Equal(t, g.GenesisTime(), genTime)
assert.Equal(t, g.Params().BondInterval, uint32(120))
expected, _ := hash.FromString("63f32d682050bd03eb832c9d99fc3b48855d7f4193e5c09205be68d6e16546af")
expected, _ := hash.FromString("f5718d6686a1a1066749a671b67b8e9506709c3e6326e6216a4a09ada56a6b01")
assert.Equal(t, g.Hash(), expected)
}

Expand Down
45 changes: 23 additions & 22 deletions genesis/testnet.json
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
{
"GenesisTime": "2023-05-08T00:00:00Z",
"Params": {
"BlockVersion": 63,
"BlockTimeInSecond": 10,
"CommitteeSize": 21,
"BlockReward": 1000000000,
"TransactionToLiveInterval": 2880,
"SortitionInterval": 7,
"BondInterval": 120,
"UnbondInterval": 60480,
"FeeFraction": 0.0001,
"MinimumFee": 1000,
"MaximumFee": 1000000,
"MaximumStake": 1000000000000
"genesis_time": "2023-05-08T00:00:00Z",
"params": {
"block_version": 63,
"block_time_in_second": 10,
"committee_size": 21,
"block_reward": 1000000000,
"transaction_to_live_interval": 2880,
"sortition_interval": 7,
"bond_interval": 120,
"unbond_interval": 60480,
"fee_fraction": 0.0001,
"minimum_fee": 1000,
"maximum_fee": 1000000,
"minimum_stake": 1000000000,
"maximum_stake": 1000000000000
},
"Accounts": [
"accounts": [
{
"Address": "000000000000000000000000000000000000000000",
"Balance": 21000000000000000
"address": "000000000000000000000000000000000000000000",
"balance": 21000000000000000
}
],
"Validators": [
"validators": [
{
"PublicKey": "tpublic1p5gw4naty9nyzqhqll3x6mk56d675908th62t3ezt2d822z3xzs2gl5907gu0fpeederje9ecks5lcrn2a8svatrsjwterv9hwzfqk7lf5rn43aee5kvfv8vfy87z9ecdnrzcv55zpt94xrgpm6nxkxxxfsadjr8q"
"public_key": "tpublic1p5gw4naty9nyzqhqll3x6mk56d675908th62t3ezt2d822z3xzs2gl5907gu0fpeederje9ecks5lcrn2a8svatrsjwterv9hwzfqk7lf5rn43aee5kvfv8vfy87z9ecdnrzcv55zpt94xrgpm6nxkxxxfsadjr8q"
},
{
"PublicKey": "tpublic1psxph0f83gx7ay26z948m8qutnal3qlmc79caacn3kgfl6gml7cqt3yrh3kgdkxqyxxl7vc9mpnutjxzt0nnkw2h4zzwlp264dznz0ssp2lytl79a395977065ygpqsm2cm3ln44ag0g28689xuwfj6u08qqu8wl6"
"public_key": "tpublic1psxph0f83gx7ay26z948m8qutnal3qlmc79caacn3kgfl6gml7cqt3yrh3kgdkxqyxxl7vc9mpnutjxzt0nnkw2h4zzwlp264dznz0ssp2lytl79a395977065ygpqsm2cm3ln44ag0g28689xuwfj6u08qqu8wl6"
},
{
"PublicKey": "tpublic1p42tae04aa40ltshyryeet7hm5050h0fdla9w988lr98emly8g9eqrkz8xg6qq3rqhg8pelps9zlrqz6xfge0w2uq6ksyxearzmha9zmdyzcagx0pe6kcfx57chfa8u4s37uftza0c75xj40x0w0khfha0cpgaua4"
"public_key": "tpublic1p42tae04aa40ltshyryeet7hm5050h0fdla9w988lr98emly8g9eqrkz8xg6qq3rqhg8pelps9zlrqz6xfge0w2uq6ksyxearzmha9zmdyzcagx0pe6kcfx57chfa8u4s37uftza0c75xj40x0w0khfha0cpgaua4"
},
{
"PublicKey": "tpublic1p5a77fv2rwgs6ywsutawwcpfqascd82nygmsnsdr7mghey0jp48q3qgywumtmelc4zurexua8kgqtyr829uqm8tju99sydxx5akhlgrdzz5lu0jgtepct4lglqhk446awj6h2nk49eweswhljkfs3dfe8esy0k6qa"
"public_key": "tpublic1p5a77fv2rwgs6ywsutawwcpfqascd82nygmsnsdr7mghey0jp48q3qgywumtmelc4zurexua8kgqtyr829uqm8tju99sydxx5akhlgrdzz5lu0jgtepct4lglqhk446awj6h2nk49eweswhljkfs3dfe8esy0k6qa"
}
]
}
26 changes: 13 additions & 13 deletions types/param/param.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ package param
import "time"

type Params struct {
BlockVersion uint8 `cbor:"1,keyasint"`
BlockTimeInSecond int `cbor:"2,keyasint"`
CommitteeSize int `cbor:"3,keyasint"`
BlockReward int64 `cbor:"4,keyasint"`
TransactionToLiveInterval uint32 `cbor:"5,keyasint"`
BondInterval uint32 `cbor:"6,keyasint"`
UnbondInterval uint32 `cbor:"7,keyasint"`
SortitionInterval uint32 `cbor:"8,keyasint"`
FeeFraction float64 `cbor:"9,keyasint"`
MinimumFee int64 `cbor:"10,keyasint"`
MaximumFee int64 `cbor:"11,keyasint"`
MinimumStake int64 `cobr:"12,keyasint"`
MaximumStake int64 `cbor:"13,keyasint"`
BlockVersion uint8 `cbor:"1,keyasint" json:"block_version"`
BlockTimeInSecond int `cbor:"2,keyasint" json:"block_time_in_second"`
CommitteeSize int `cbor:"3,keyasint" json:"committee_size"`
BlockReward int64 `cbor:"4,keyasint" json:"block_reward"`
TransactionToLiveInterval uint32 `cbor:"5,keyasint" json:"transaction_to_live_interval"`
BondInterval uint32 `cbor:"6,keyasint" json:"bond_interval"`
UnbondInterval uint32 `cbor:"7,keyasint" json:"unbond_interval"`
SortitionInterval uint32 `cbor:"8,keyasint" json:"sortition_interval"`
FeeFraction float64 `cbor:"9,keyasint" json:"fee_fraction"`
MinimumFee int64 `cbor:"10,keyasint" json:"minimum_fee"`
MaximumFee int64 `cbor:"11,keyasint" json:"maximum_fee"`
MinimumStake int64 `cobr:"12,keyasint" json:"minimum_stake"`
MaximumStake int64 `cbor:"13,keyasint" json:"maximum_stake"`
}

func DefaultParams() Params {
Expand Down
2 changes: 1 addition & 1 deletion types/validator/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func (val *Validator) SerializeSize() int {
return 124 // 96+4+4+8+4+4+4
}

// Bytes returns returns the serialized byte representation of the validator.
// Bytes returns the serialized byte representation of the validator.
func (val *Validator) Bytes() ([]byte, error) {
w := bytes.NewBuffer(make([]byte, 0, val.SerializeSize()))

Expand Down
5 changes: 4 additions & 1 deletion wallet/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ func (s *store) Save(bs []byte) error {
}

func (s *store) calcVaultCRC() uint32 {
d, _ := json.Marshal(s.Vault)
d, err := json.Marshal(s.Vault)
if err != nil {
return 0
}
return crc32.ChecksumIEEE(d)
}
10 changes: 5 additions & 5 deletions wallet/vault/vault_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,26 +316,26 @@ func TestValidateMnemonic(t *testing.T) {
"Invalid mnenomic",
},
{
"abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon",
"abandon ability able about above absent absorb abstract absurd abuse access",
"Invalid mnenomic",
},
{
"bandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon",
"bandon ability able about above absent absorb abstract absurd abuse access ability",
"word `bandon` not found in reverse map",
},
{
"abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon",
"abandon ability able about above absent absorb abstract absurd abuse access accident",
"Checksum incorrect",
},
{
"abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon cactus",
"abandon ability able about above absent absorb abstract absurd abuse access ability",
"",
},
}
for i, test := range tests {
err := CheckMnemonic(test.mnenomic)
if err != nil {
assert.ErrorContains(t, err, test.errStr, "test %v failed", i)
assert.Equal(t, err.Error(), test.errStr, "test %v failed", i)
}
}
}

0 comments on commit 1fb44c8

Please sign in to comment.