Skip to content

Commit

Permalink
Merge branch 'develop' into FD-250c
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulSnow committed Sep 22, 2017
2 parents 5bce21b + fb1e51e commit 24c6747
Show file tree
Hide file tree
Showing 46 changed files with 225 additions and 384 deletions.
4 changes: 2 additions & 2 deletions common/adminBlock/EntryAddAuditServer.go
Expand Up @@ -10,8 +10,8 @@ import (

// DB Signature Entry -------------------------
type AddAuditServer struct {
IdentityChainID interfaces.IHash
DBHeight uint32
IdentityChainID interfaces.IHash `json:"identitychainid"`
DBHeight uint32 `json:"dbheight"`
}

var _ interfaces.IABEntry = (*AddAuditServer)(nil)
Expand Down
4 changes: 2 additions & 2 deletions common/adminBlock/EntryAddAuditServer_test.go
Expand Up @@ -102,14 +102,14 @@ func TestAddAuditServerMisc(t *testing.T) {
if err != nil {
t.Error(err)
}
if as != "{\"IdentityChainID\":\"0000000000000000000000000000000000000000000000000000000000000000\",\"DBHeight\":0}" {
if as != "{\"identitychainid\":\"0000000000000000000000000000000000000000000000000000000000000000\",\"dbheight\":0}" {
t.Error("Unexpected JSON string:", as)
}
ab, err := a.JSONByte()
if err != nil {
t.Error(err)
}
if string(ab) != "{\"IdentityChainID\":\"0000000000000000000000000000000000000000000000000000000000000000\",\"DBHeight\":0}" {
if string(ab) != "{\"identitychainid\":\"0000000000000000000000000000000000000000000000000000000000000000\",\"dbheight\":0}" {
t.Error("Unexpected JSON bytes:", as)
}

Expand Down
4 changes: 2 additions & 2 deletions common/adminBlock/EntryAddFederatedServer.go
Expand Up @@ -10,8 +10,8 @@ import (

// DB Signature Entry -------------------------
type AddFederatedServer struct {
IdentityChainID interfaces.IHash
DBHeight uint32
IdentityChainID interfaces.IHash `json:"identitychainid"`
DBHeight uint32 `json:"dbheight"`
}

var _ interfaces.IABEntry = (*AddFederatedServer)(nil)
Expand Down
8 changes: 4 additions & 4 deletions common/adminBlock/EntryAddFederatedServerBitcoinAnchorKey.go
Expand Up @@ -10,10 +10,10 @@ import (

// DB Signature Entry -------------------------
type AddFederatedServerBitcoinAnchorKey struct {
IdentityChainID interfaces.IHash
KeyPriority byte
KeyType byte //0=P2PKH 1=P2SH
ECDSAPublicKey primitives.ByteSlice20
IdentityChainID interfaces.IHash `json:"identitychainid"`
KeyPriority byte `json:"keypriority"`
KeyType byte `json:"keytype"` //0=P2PKH 1=P2SH
ECDSAPublicKey primitives.ByteSlice20 `json:"ecdsapublickey"`
}

var _ interfaces.IABEntry = (*AddFederatedServerBitcoinAnchorKey)(nil)
Expand Down
8 changes: 4 additions & 4 deletions common/adminBlock/EntryAddFederatedServerSigningKey.go
Expand Up @@ -10,10 +10,10 @@ import (

// DB Signature Entry -------------------------
type AddFederatedServerSigningKey struct {
IdentityChainID interfaces.IHash
KeyPriority byte
PublicKey primitives.PublicKey
DBHeight uint32
IdentityChainID interfaces.IHash `json:"identitychainid"`
KeyPriority byte `json:"keypriority"`
PublicKey primitives.PublicKey `json:"publickey"`
DBHeight uint32 `json:"dbheight"`
}

var _ interfaces.IABEntry = (*AddFederatedServerSigningKey)(nil)
Expand Down
4 changes: 2 additions & 2 deletions common/adminBlock/EntryAddFederatedServer_test.go
Expand Up @@ -102,14 +102,14 @@ func TestAddFedServerMisc(t *testing.T) {
if err != nil {
t.Error(err)
}
if as != "{\"IdentityChainID\":\"0000000000000000000000000000000000000000000000000000000000000000\",\"DBHeight\":0}" {
if as != "{\"identitychainid\":\"0000000000000000000000000000000000000000000000000000000000000000\",\"dbheight\":0}" {
t.Error("Unexpected JSON string:", as)
}
ab, err := a.JSONByte()
if err != nil {
t.Error(err)
}
if string(ab) != "{\"IdentityChainID\":\"0000000000000000000000000000000000000000000000000000000000000000\",\"DBHeight\":0}" {
if string(ab) != "{\"identitychainid\":\"0000000000000000000000000000000000000000000000000000000000000000\",\"dbheight\":0}" {
t.Error("Unexpected JSON bytes:", as)
}

Expand Down
4 changes: 2 additions & 2 deletions common/adminBlock/EntryAddReplaceMatryoshkaHash.go
Expand Up @@ -9,8 +9,8 @@ import (
)

type AddReplaceMatryoshkaHash struct {
IdentityChainID interfaces.IHash
MHash interfaces.IHash
IdentityChainID interfaces.IHash `json:"identitychainid"`
MHash interfaces.IHash `json:"mhash"`
}

var _ interfaces.Printable = (*AddReplaceMatryoshkaHash)(nil)
Expand Down
4 changes: 2 additions & 2 deletions common/adminBlock/EntryAddReplaceMatryoshkaHash_test.go
Expand Up @@ -102,14 +102,14 @@ func TestAddMatryoshkaHashMisc(t *testing.T) {
if err != nil {
t.Error(err)
}
if as != "{\"IdentityChainID\":\"0000000000000000000000000000000000000000000000000000000000000000\",\"MHash\":\"0000000000000000000000000000000000000000000000000000000000000000\"}" {
if as != "{\"identitychainid\":\"0000000000000000000000000000000000000000000000000000000000000000\",\"mhash\":\"0000000000000000000000000000000000000000000000000000000000000000\"}" {
t.Error("Unexpected JSON string:", as)
}
ab, err := a.JSONByte()
if err != nil {
t.Error(err)
}
if string(ab) != "{\"IdentityChainID\":\"0000000000000000000000000000000000000000000000000000000000000000\",\"MHash\":\"0000000000000000000000000000000000000000000000000000000000000000\"}" {
if string(ab) != "{\"identitychainid\":\"0000000000000000000000000000000000000000000000000000000000000000\",\"mhash\":\"0000000000000000000000000000000000000000000000000000000000000000\"}" {
t.Error("Unexpected JSON bytes:", as)
}

Expand Down
4 changes: 2 additions & 2 deletions common/adminBlock/EntryDBSignature.go
Expand Up @@ -10,8 +10,8 @@ import (

// DB Signature Entry -------------------------
type DBSignatureEntry struct {
IdentityAdminChainID interfaces.IHash
PrevDBSig primitives.Signature
IdentityAdminChainID interfaces.IHash `json:"identityadminchainid"`
PrevDBSig primitives.Signature `json:"prevdbsig"`
}

var _ interfaces.IABEntry = (*DBSignatureEntry)(nil)
Expand Down
2 changes: 1 addition & 1 deletion common/adminBlock/EntryEndOfMinute.go
Expand Up @@ -9,7 +9,7 @@ import (
)

type EndOfMinuteEntry struct {
MinuteNumber byte
MinuteNumber byte `json:"minutenumber"`
}

var _ interfaces.Printable = (*EndOfMinuteEntry)(nil)
Expand Down
2 changes: 1 addition & 1 deletion common/adminBlock/EntryIncreaseServerCount.go
Expand Up @@ -10,7 +10,7 @@ import (

// DB Signature Entry -------------------------
type IncreaseServerCount struct {
Amount byte
Amount byte `json:"amount"`
}

var _ interfaces.IABEntry = (*IncreaseServerCount)(nil)
Expand Down
4 changes: 2 additions & 2 deletions common/adminBlock/EntryRemoveFederatedServer.go
Expand Up @@ -10,8 +10,8 @@ import (

// DB Signature Entry -------------------------
type RemoveFederatedServer struct {
IdentityChainID interfaces.IHash
DBHeight uint32
IdentityChainID interfaces.IHash `json:"identitychainid"`
DBHeight uint32 `json:"dbheight"`
}

var _ interfaces.IABEntry = (*RemoveFederatedServer)(nil)
Expand Down
4 changes: 2 additions & 2 deletions common/adminBlock/EntryRevealMatryoshkaHash.go
Expand Up @@ -9,8 +9,8 @@ import (
)

type RevealMatryoshkaHash struct {
IdentityChainID interfaces.IHash
MHash interfaces.IHash
IdentityChainID interfaces.IHash `json:"identitychainid"`
MHash interfaces.IHash `json:"mhash"`
}

var _ interfaces.Printable = (*RevealMatryoshkaHash)(nil)
Expand Down
14 changes: 7 additions & 7 deletions common/adminBlock/EntryServerFault.go
Expand Up @@ -9,16 +9,16 @@ import (
)

type ServerFault struct {
Timestamp interfaces.Timestamp
Timestamp interfaces.Timestamp `json:"timestamp"`
// The following 4 fields represent the "Core" of the message
// This should match the Core of ServerFault messages
ServerID interfaces.IHash
AuditServerID interfaces.IHash
VMIndex byte
DBHeight uint32
Height uint32
ServerID interfaces.IHash `json:"serverid"`
AuditServerID interfaces.IHash `json:"auditserverid"`
VMIndex byte `json:"vmindex"`
DBHeight uint32 `json:"dbheight"`
Height uint32 `json:"height"`

SignatureList SigList
SignatureList SigList `json:"signaturelist"`
}

func (e *ServerFault) Init() {
Expand Down
10 changes: 5 additions & 5 deletions common/adminBlock/adminBlock.go
Expand Up @@ -21,8 +21,8 @@ import (
// https://github.com/FactomProject/FactomDocs/blob/master/factomDataStructureDetails.md#administrative-block
type AdminBlock struct {
//Marshalized
Header interfaces.IABlockHeader
ABEntries []interfaces.IABEntry //Interface
Header interfaces.IABlockHeader `json:"header"`
ABEntries []interfaces.IABEntry `json:"abentries"` //Interface
}

var _ interfaces.IAdminBlock = (*AdminBlock)(nil)
Expand Down Expand Up @@ -61,7 +61,7 @@ func (c *AdminBlock) String() string {
out.WriteString(fmt.Sprintf("%20s %x\n", "512 Sha3:", fh.Bytes()))

out.WriteString(c.GetHeader().String())
out.WriteString("Entries: \n")
out.WriteString("entries: \n")
for _, entry := range c.ABEntries {
out.WriteString(entry.String() + "\n")
}
Expand Down Expand Up @@ -443,8 +443,8 @@ func (e AdminBlock) MarshalJSON() ([]byte, error) {

return json.Marshal(struct {
ExpandedABlock
BackReferenceHash string
LookupHash string
BackReferenceHash string `json:"backreferencehash"`
LookupHash string `json:"lookuphash"`
}{
ExpandedABlock: ExpandedABlock(e),
BackReferenceHash: backRefHash.String(),
Expand Down
16 changes: 8 additions & 8 deletions common/adminBlock/adminBlockHeader.go
Expand Up @@ -17,13 +17,13 @@ import (

// Admin Block Header
type ABlockHeader struct {
PrevBackRefHash interfaces.IHash
DBHeight uint32
PrevBackRefHash interfaces.IHash `json:"prevbackrefhash"`
DBHeight uint32 `json:"dbheight"`

HeaderExpansionSize uint64
HeaderExpansionArea []byte
MessageCount uint32
BodySize uint32
HeaderExpansionSize uint64 `json:"headerexpansionsize"`
HeaderExpansionArea []byte `json:"headerexpansionarea"`
MessageCount uint32 `json:"messagecount"`
BodySize uint32 `json:"bodysize"`
}

var _ interfaces.Printable = (*ABlockHeader)(nil)
Expand Down Expand Up @@ -226,8 +226,8 @@ type ExpandedABlockHeader ABlockHeader
func (e ABlockHeader) MarshalJSON() ([]byte, error) {
return json.Marshal(struct {
ExpandedABlockHeader
AdminChainID string
ChainID string
AdminChainID string `json:"adminchainid"`
ChainID string `json:"chainid"`
}{
ExpandedABlockHeader: ExpandedABlockHeader(e),
AdminChainID: "000000000000000000000000000000000000000000000000000000000000000a",
Expand Down
8 changes: 4 additions & 4 deletions common/adminBlock/adminBlock_test.go
Expand Up @@ -401,10 +401,10 @@ func TestAdminBlockHash(t *testing.T) {
if err != nil {
t.Errorf("%v", err)
}
if strings.Contains(j, `"BackReferenceHash":"9515e5108c89ef004ff4fa01c6511f98c8c11f5c2976c4816f8bcfcc551a134d"`) == false {
if strings.Contains(j, `"backreferencehash":"9515e5108c89ef004ff4fa01c6511f98c8c11f5c2976c4816f8bcfcc551a134d"`) == false {
t.Errorf("JSON printout does not contain the backreference hash - %v", j)
}
if strings.Contains(j, `"LookupHash":"f10eefb55197e34f2875c1727c816fcf6564a44902b716a380f0961406ff92d5"`) == false {
if strings.Contains(j, `"lookuphash":"f10eefb55197e34f2875c1727c816fcf6564a44902b716a380f0961406ff92d5"`) == false {
t.Errorf("JSON printout does not contain the lookup hash - %v", j)
}
}
Expand Down Expand Up @@ -672,10 +672,10 @@ func TestExpandedABlockHeader(t *testing.T) {
t.Error(err)
t.FailNow()
}
if !strings.Contains(j, `"AdminChainID":"000000000000000000000000000000000000000000000000000000000000000a"`) {
if !strings.Contains(j, `"adminchainid":"000000000000000000000000000000000000000000000000000000000000000a"`) {
t.Error("Header does not contain AdminChainID")
}
if !strings.Contains(j, `"ChainID":"000000000000000000000000000000000000000000000000000000000000000a"`) {
if !strings.Contains(j, `"chainid":"000000000000000000000000000000000000000000000000000000000000000a"`) {
t.Error("Header does not contain ChainID")
}
}
Expand Down
18 changes: 9 additions & 9 deletions common/directoryBlock/directoryBlock.go
Expand Up @@ -19,13 +19,13 @@ var _ = fmt.Print

type DirectoryBlock struct {
//Not Marshalized
DBHash interfaces.IHash
KeyMR interfaces.IHash
keyMRset bool
DBHash interfaces.IHash `json:"dbhash"`
KeyMR interfaces.IHash `json:"keymr"`
keyMRset bool `json:"keymrset"`

//Marshalized
Header interfaces.IDirectoryBlockHeader
DBEntries []interfaces.IDBEntry
Header interfaces.IDirectoryBlockHeader `json:"header"`
DBEntries []interfaces.IDBEntry `json:"dbentries"`
}

var _ interfaces.Printable = (*DirectoryBlock)(nil)
Expand Down Expand Up @@ -245,16 +245,16 @@ func (e *DirectoryBlock) String() string {
var out primitives.Buffer

kmr := e.GetKeyMR()
out.WriteString(fmt.Sprintf("%20s %v\n", "KeyMR:", kmr.String()))
out.WriteString(fmt.Sprintf("%20s %v\n", "keymr:", kmr.String()))

kmr = e.BodyKeyMR()
out.WriteString(fmt.Sprintf("%20s %v\n", "BodyMR:", kmr.String()))
out.WriteString(fmt.Sprintf("%20s %v\n", "bodymr:", kmr.String()))

fh := e.GetFullHash()
out.WriteString(fmt.Sprintf("%20s %v\n", "FullHash:", fh.String()))
out.WriteString(fmt.Sprintf("%20s %v\n", "fullhash:", fh.String()))

out.WriteString(e.GetHeader().String())
out.WriteString("Entries: \n")
out.WriteString("entries: \n")
for i, entry := range e.DBEntries {
out.WriteString(fmt.Sprintf("%5d %s", i, entry.String()))
}
Expand Down
8 changes: 4 additions & 4 deletions common/directoryBlock/directoryBlockEntry.go
Expand Up @@ -14,8 +14,8 @@ import (
var _ = fmt.Print

type DBEntry struct {
ChainID interfaces.IHash
KeyMR interfaces.IHash // Different MR in EBlockHeader
ChainID interfaces.IHash `json:"chainid"`
KeyMR interfaces.IHash `json:"keymr"` // Different MR in EBlockHeader
}

var _ interfaces.Printable = (*DBEntry)(nil)
Expand Down Expand Up @@ -117,7 +117,7 @@ func (e *DBEntry) JSONString() (string, error) {

func (e *DBEntry) String() string {
var out primitives.Buffer
out.WriteString("ChainID: " + e.GetChainID().String() + "\n")
out.WriteString(" KeyMR: " + e.GetKeyMR().String() + "\n")
out.WriteString("chainid: " + e.GetChainID().String() + "\n")
out.WriteString(" keymr: " + e.GetKeyMR().String() + "\n")
return (string)(out.DeepCopyBytes())
}
9 changes: 5 additions & 4 deletions common/directoryBlock/directoryBlockEntry_test.go
Expand Up @@ -6,9 +6,10 @@ package directoryBlock_test

import (
"fmt"
"testing"

. "github.com/FactomProject/factomd/common/directoryBlock"
"github.com/FactomProject/factomd/common/primitives"
"testing"
)

func TestUnmarshalNilDBEntry(t *testing.T) {
Expand Down Expand Up @@ -141,8 +142,8 @@ func TestPrintsE(t *testing.T) {
dbe.SetKeyMR(h)
returnVal := dbe.String()

expectedString := `ChainID: 3e3eb61fb20e71d8211882075d404f5929618a189d23aba8c892b22228aa0d71
KeyMR: 9daad42e5efedf3075fa2cf51908babdb568f431a3c13b9a496ffbfb7160ad2e
expectedString := `chainid: 3e3eb61fb20e71d8211882075d404f5929618a189d23aba8c892b22228aa0d71
keymr: 9daad42e5efedf3075fa2cf51908babdb568f431a3c13b9a496ffbfb7160ad2e
`

if returnVal != expectedString {
Expand All @@ -154,7 +155,7 @@ func TestPrintsE(t *testing.T) {
returnVal, _ = dbe.JSONString()
//fmt.Println(returnVal)

expectedString = `{"ChainID":"3e3eb61fb20e71d8211882075d404f5929618a189d23aba8c892b22228aa0d71","KeyMR":"9daad42e5efedf3075fa2cf51908babdb568f431a3c13b9a496ffbfb7160ad2e"}`
expectedString = `{"chainid":"3e3eb61fb20e71d8211882075d404f5929618a189d23aba8c892b22228aa0d71","keymr":"9daad42e5efedf3075fa2cf51908babdb568f431a3c13b9a496ffbfb7160ad2e"}`
if returnVal != expectedString {
fmt.Println("got", returnVal)
fmt.Println("expected", expectedString)
Expand Down

0 comments on commit 24c6747

Please sign in to comment.