reverted breaking changes

This commit is contained in:
StephenButtolph 2020-06-18 01:45:58 -04:00
parent 45b9a230b6
commit be6be7ae1c
8 changed files with 69 additions and 67 deletions

View File

@ -26,8 +26,8 @@ func TestNetworkName(t *testing.T) {
if name := NetworkName(EverestID); name != EverestName {
t.Fatalf("NetworkID was incorrectly named. Result: %s ; Expected: %s", name, EverestName)
}
if name := NetworkName(TestnetID); name != EverestName {
t.Fatalf("NetworkID was incorrectly named. Result: %s ; Expected: %s", name, EverestName)
if name := NetworkName(DenaliID); name != DenaliName {
t.Fatalf("NetworkID was incorrectly named. Result: %s ; Expected: %s", name, DenaliName)
}
if name := NetworkName(4294967295); name != "network-4294967295" {
t.Fatalf("NetworkID was incorrectly named. Result: %s ; Expected: %s", name, "network-4294967295")

View File

@ -18,7 +18,7 @@ var (
DenaliID uint32 = 3
EverestID uint32 = 4
TestnetID uint32 = 4
TestnetID uint32 = 3
LocalID uint32 = 12345
MainnetName = "mainnet"

View File

@ -30,7 +30,7 @@ import (
)
const (
dbVersion = "v0.6.0"
dbVersion = "v0.5.0"
)
// Results of parsing the CLI

View File

@ -170,21 +170,23 @@ const (
Version
GetPeerList
PeerList
Ping
Pong
// Bootstrapping:
GetAcceptedFrontier
AcceptedFrontier
GetAccepted
Accepted
GetAncestors
MultiPut
// Consensus:
Get
Put
PushQuery
PullQuery
Chits
// TODO: Reorder these messages when we transition to everest
GetAncestors
MultiPut
Ping
Pong
)
// Defines the messages that can be sent/received with this network

View File

@ -64,7 +64,7 @@ func (p *peer) Start() {
// Initially send the version to the peer
go p.Version()
go p.requestVersion()
go p.sendPings()
// go p.sendPings()
}
func (p *peer) sendPings() {
@ -107,10 +107,10 @@ func (p *peer) requestVersion() {
func (p *peer) ReadMessages() {
defer p.Close()
if err := p.conn.SetReadDeadline(p.net.clock.Time().Add(p.net.pingPongTimeout)); err != nil {
p.net.log.Verbo("error on setting the connection read timeout %s", err)
return
}
// if err := p.conn.SetReadDeadline(p.net.clock.Time().Add(p.net.pingPongTimeout)); err != nil {
// p.net.log.Verbo("error on setting the connection read timeout %s", err)
// return
// }
pendingBuffer := wrappers.Packer{}
readBuffer := make([]byte, 1<<10)
@ -246,11 +246,11 @@ func (p *peer) handle(msg Msg) {
currentTime := p.net.clock.Time()
atomic.StoreInt64(&p.lastReceived, currentTime.Unix())
if err := p.conn.SetReadDeadline(currentTime.Add(p.net.pingPongTimeout)); err != nil {
p.net.log.Verbo("error on setting the connection read timeout %s, closing the connection", err)
p.Close()
return
}
// if err := p.conn.SetReadDeadline(currentTime.Add(p.net.pingPongTimeout)); err != nil {
// p.net.log.Verbo("error on setting the connection read timeout %s, closing the connection", err)
// p.Close()
// return
// }
op := msg.Op()
msgMetrics := p.net.message(op)

View File

@ -57,7 +57,7 @@ var (
genesisHashKey = []byte("genesisID")
// Version is the version of this code
Version = version.NewDefaultVersion("avalanche", 0, 6, 0)
Version = version.NewDefaultVersion("avalanche", 0, 5, 5)
versionParser = version.NewDefaultParser()
)

View File

@ -128,7 +128,7 @@ func (tx *addDefaultSubnetDelegatorTx) SemanticVerify(db database.Database) (*ve
// The account if this block's proposal is committed and the validator is
// added to the pending validator set. (Increase the account's nonce;
// decrease its balance.)
newAccount, err := account.Remove(tx.Wght, tx.Nonce) // Remove also removes the fee
newAccount, err := account.Remove(0, tx.Nonce) // Remove also removes the fee
if err != nil {
return nil, nil, nil, nil, permError{err}
}

View File

@ -335,9 +335,9 @@ func TestAddDefaultSubnetDelegatorTxSemanticVerify(t *testing.T) {
}
tx, err = vm.newAddDefaultSubnetDelegatorTx(
defaultNonce+1, // nonce
defaultStakeAmount, // weight
uint64(newTimestamp.Unix()), // start time
defaultNonce+1, // nonce
defaultStakeAmount, // weight
uint64(newTimestamp.Unix()), // start time
uint64(newTimestamp.Add(MinimumStakingDuration).Unix()), // end time
defaultKey.PublicKey().Address(), // node ID
defaultKey.PublicKey().Address(), // destination
@ -387,51 +387,51 @@ func TestAddDefaultSubnetDelegatorTxSemanticVerify(t *testing.T) {
}
txFee = txFeeSaved // Reset tx fee
// Case 8: fail verification for spending more funds than it has
tx, err = vm.newAddDefaultSubnetDelegatorTx(
defaultNonce+1,
defaultBalance*2, // weight
uint64(defaultValidateStartTime.Unix()), // start time
uint64(defaultValidateEndTime.Unix()), // end time
defaultKey.PublicKey().Address(), // node ID
defaultKey.PublicKey().Address(), // destination
testNetworkID, // network ID
defaultKey, // tx fee payer
)
if err != nil {
t.Fatal(err)
}
_, _, _, _, err = tx.SemanticVerify(vm.DB)
if err == nil {
t.Fatal("should have failed verification because payer account spent twice the account's balance")
}
// // Case 8: fail verification for spending more funds than it has
// tx, err = vm.newAddDefaultSubnetDelegatorTx(
// defaultNonce+1,
// defaultBalance*2, // weight
// uint64(defaultValidateStartTime.Unix()), // start time
// uint64(defaultValidateEndTime.Unix()), // end time
// defaultKey.PublicKey().Address(), // node ID
// defaultKey.PublicKey().Address(), // destination
// testNetworkID, // network ID
// defaultKey, // tx fee payer
// )
// if err != nil {
// t.Fatal(err)
// }
// _, _, _, _, err = tx.SemanticVerify(vm.DB)
// if err == nil {
// t.Fatal("should have failed verification because payer account spent twice the account's balance")
// }
// Case 9: Confirm balance is correct
tx, err = vm.newAddDefaultSubnetDelegatorTx(
defaultNonce+1,
defaultStakeAmount, // weight
uint64(defaultValidateStartTime.Unix()), // start time
uint64(defaultValidateEndTime.Unix()), // end time
defaultKey.PublicKey().Address(), // node ID
defaultKey.PublicKey().Address(), // destination
testNetworkID, // network ID
defaultKey, // tx fee payer
)
if err != nil {
t.Fatal(err)
}
// // Case 9: Confirm balance is correct
// tx, err = vm.newAddDefaultSubnetDelegatorTx(
// defaultNonce+1,
// defaultStakeAmount, // weight
// uint64(defaultValidateStartTime.Unix()), // start time
// uint64(defaultValidateEndTime.Unix()), // end time
// defaultKey.PublicKey().Address(), // node ID
// defaultKey.PublicKey().Address(), // destination
// testNetworkID, // network ID
// defaultKey, // tx fee payer
// )
// if err != nil {
// t.Fatal(err)
// }
onCommitDB, _, _, _, err := tx.SemanticVerify(vm.DB)
if err != nil {
t.Fatal(err)
}
account, err := tx.vm.getAccount(onCommitDB, defaultKey.PublicKey().Address())
if err != nil {
t.Fatal(err)
}
balance := account.Balance
// onCommitDB, _, _, _, err := tx.SemanticVerify(vm.DB)
// if err != nil {
// t.Fatal(err)
// }
// account, err := tx.vm.getAccount(onCommitDB, defaultKey.PublicKey().Address())
// if err != nil {
// t.Fatal(err)
// }
// balance := account.Balance
if balance != defaultBalance-(defaultStakeAmount+txFee) {
t.Fatalf("balance was not updated correctly after subnet delegator tx")
}
// if balance != defaultBalance-(defaultStakeAmount+txFee) {
// t.Fatalf("balance was not updated correctly after subnet delegator tx")
// }
}