-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3347683
commit 9801a0b
Showing
25 changed files
with
640 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [Unreleased] | ||
|
||
## [0.0.4] - 2022-08-17 | ||
### Added | ||
- Introduce provider filters with `enforce` and `providers` filters | ||
### Changed | ||
- Make temporary deployment file location cross-platform | ||
### Fixed | ||
- `net` field in provider configuration had wrong default value | ||
- Bug where cheapest bids were not being selected | ||
- Issue where gas adjustment was not enough on deployment update | ||
### Development | ||
- More unit tests | ||
- Implemented several string utilities including `CointainsAny` and `FindAll` functions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package extensions | ||
|
||
func Union[T comparable](a []T, b []T) []T { | ||
ch := make(chan T, len(b)) | ||
|
||
for _, bElem := range b { | ||
go func(t T) { | ||
if Contains(a, t) { | ||
ch <- t | ||
} else { | ||
var zeroValue T | ||
ch <- zeroValue | ||
} | ||
}(bElem) | ||
} | ||
|
||
finds := make([]T, 0) | ||
var zeroValue T | ||
|
||
for range b { | ||
s := <-ch | ||
if s != zeroValue { | ||
finds = append(finds, s) | ||
} | ||
} | ||
|
||
return finds | ||
} | ||
|
||
func Contains[T comparable](s []T, e T) bool { | ||
for _, a := range s { | ||
if a == e { | ||
return true | ||
} | ||
} | ||
return false | ||
} | ||
|
||
func ContainsAny[T comparable](a []T, b []T) bool { | ||
ch := make(chan bool, len(b)) | ||
|
||
for _, str := range b { | ||
go func(s T) { | ||
ch <- Contains(a, s) | ||
}(str) | ||
} | ||
|
||
for range b { | ||
contains := <-ch | ||
if contains { | ||
return true | ||
} | ||
} | ||
|
||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package extensions | ||
|
||
import "testing" | ||
|
||
func TestContains(t *testing.T) { | ||
testSlice := []string{"A", "B", "C", "D", "test", "F"} | ||
|
||
t.Run("should return true if slice contains value", func(t *testing.T) { | ||
if !Contains(testSlice, "test") { | ||
t.Errorf("Expected slice to contain %s", testSlice) | ||
} | ||
}) | ||
|
||
t.Run("should return false if slice contains value", func(t *testing.T) { | ||
if Contains(testSlice, "Non-existent test") { | ||
t.Errorf("Expected slice not to contain %s", testSlice) | ||
} | ||
}) | ||
} | ||
|
||
func TestContainsAny(t *testing.T) { | ||
testSlice := []string{"A", "B", "C", "D", "test", "F"} | ||
|
||
t.Run("should return true if slice contains any value", func(t *testing.T) { | ||
if !ContainsAny(testSlice, []string{"yes", "test", "hello", "there"}) { | ||
t.Errorf("Expected slice to contain %s", testSlice) | ||
} | ||
}) | ||
|
||
t.Run("should return false if slice contains any value", func(t *testing.T) { | ||
if ContainsAny(testSlice, []string{"Non-existent test"}) { | ||
t.Errorf("Expected slice not to contain %s", testSlice) | ||
} | ||
}) | ||
} | ||
|
||
func TestUnion(t *testing.T) { | ||
type Test struct{ x string } | ||
testSlice := []Test{{"A"}, {"B"}, {"C"}, {"D"}, {"test"}, {"F"}} | ||
|
||
t.Run("should return a slice containing finds", func(t *testing.T) { | ||
finds := Union(testSlice, []Test{{"yes"}, {"test"}, {"A"}, {"there"}}) | ||
if len(finds) != 2 { | ||
t.Errorf("Expected to find %d but found %d (%v)", 2, len(finds), finds) | ||
} | ||
|
||
if !Contains(testSlice, finds[0]) || !Contains(testSlice, finds[1]) { | ||
t.Fail() | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package extensions | ||
|
||
func FindAll(strings []string, e []string) []string { | ||
ch := make(chan string, len(e)) | ||
|
||
for _, str := range e { | ||
go func(s string) { | ||
if Contains(strings, s) { | ||
ch <- s | ||
} else { | ||
ch <- "" | ||
} | ||
}(str) | ||
} | ||
|
||
finds := make([]string, 0) | ||
|
||
for range e { | ||
s := <-ch | ||
if s != "" { | ||
finds = append(finds, s) | ||
} | ||
} | ||
|
||
return finds | ||
} |
Oops, something went wrong.