Skip to content

Commit

Permalink
Merge pull request #566 from moul/dev/moul/retry0.5.0
Browse files Browse the repository at this point in the history
build(ci): use retry@0.5.0
  • Loading branch information
moul committed Nov 9, 2018
2 parents ead675d + ccb1460 commit e4c3222
Show file tree
Hide file tree
Showing 18 changed files with 80 additions and 83 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Expand Up @@ -16,8 +16,8 @@ references:
run:
name: install retry
command: |
command -v wget &>/dev/null && wget -O /tmp/retry "https://github.com/moul/retry/releases/download/v0.4.0/retry_$(uname -s)_$(uname -m)" || true
if [ ! -f /tmp/retry ]; then command -v curl &>/dev/null && curl -L -o /tmp/retry "https://github.com/moul/retry/releases/download/v0.4.0/retry_$(uname -s)_$(uname -m)"; fi
command -v wget &>/dev/null && wget -O /tmp/retry "https://github.com/moul/retry/releases/download/v0.5.0/retry_$(uname -s)_$(uname -m)" || true
if [ ! -f /tmp/retry ]; then command -v curl &>/dev/null && curl -L -o /tmp/retry "https://github.com/moul/retry/releases/download/v0.5.0/retry_$(uname -s)_$(uname -m)"; fi
chmod +x /tmp/retry
/tmp/retry --version
Expand Down
1 change: 1 addition & 0 deletions .golangci.yml
Expand Up @@ -4,6 +4,7 @@ run:
skip-files:
- ".*\\.pb\\.go"
- ".*\\.gen\\.go"
- "client/react-native/gomobile/other.go"

linters-settings:
golint:
Expand Down
1 change: 1 addition & 0 deletions Makefile
Expand Up @@ -41,6 +41,7 @@ lint-editorconfig:
! -ipath "*/built/*" \
! -ipath "*/vendor/*" \
! -ipath '*/node_modules/*' \
! -ipath '*/core/cmd/berty/banner.go' \
! -name "*.gen.*" \
! -name "*.generated.go" \
! -name "*generated*" \
Expand Down
Expand Up @@ -10,17 +10,16 @@
import static org.junit.Assert.*;

/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {

public void useAppContext() {
// Context of the app under test.
// Context appContext = InstrumentationRegistry.getTargetContext();

// assertEquals("chat.berty.ble.manager", appContext.getPackageName());
// Context appContext = InstrumentationRegistry.getTargetContext();
// assertEquals("chat.berty.ble.manager", appContext.getPackageName());
}
}
Expand Up @@ -71,15 +71,14 @@ public void write(byte[] p) throws InterruptedException {
waitReady.await();
synchronized (toSend) {

int length = p.length;
int offset = 0;
do {
int chunckSize = length - offset > mtu ? mtu : length - offset;
byte[] chunck = Arrays.copyOfRange(p, offset, chunckSize);
offset += chunckSize;
toSend.add(chunck);
} while (offset < length);

int length = p.length;
int offset = 0;
do {
int chunckSize = length - offset > mtu ? mtu : length - offset;
byte[] chunck = Arrays.copyOfRange(p, offset, chunckSize);
offset += chunckSize;
toSend.add(chunck);
} while (offset < length);

while (!toSend.isEmpty()) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
Expand Down
Expand Up @@ -365,9 +365,9 @@ public void onStartFailure(int errorCode) {
public @Nullable ScanSettings createScanSetting() {
ScanSettings settings = null;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
settings = new ScanSettings.Builder()
.setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY)
.build();
settings = new ScanSettings.Builder()
.setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY)
.build();
}
return settings;
}
Expand Down
Expand Up @@ -5,13 +5,12 @@
import static org.junit.Assert.*;

/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {

public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}
}
Expand Up @@ -219,7 +219,7 @@ export const EventListFilterModal = ({ navigation }) =>
{ value: 2, label: 'AckedAt is defined' },
]}
/>
<Button onPress={async () => await mutations.debugRequeueAll.commit({ t: true })} icon={'radio'}
<Button onPress={() => mutations.debugRequeueAll.commit({ t: true })} icon={'radio'}
style={{ textAlign: 'left' }}>
Requeue all non acked
</Button>
Expand Down
10 changes: 5 additions & 5 deletions client/react-native/ios/Berty/AppDelegate.m
Expand Up @@ -52,32 +52,32 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
// Required to register for notifications
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
[RCTPushNotificationManager didRegisterUserNotificationSettings:notificationSettings];
[RCTPushNotificationManager didRegisterUserNotificationSettings:notificationSettings];
}

// Required for the register event.
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
[RCTPushNotificationManager didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
[RCTPushNotificationManager didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}

// Required for the notification event. You must call the completion handler after handling the remote notification.
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
[RCTPushNotificationManager didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
[RCTPushNotificationManager didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}

// Required for the registrationError event.
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
{
[RCTPushNotificationManager didFailToRegisterForRemoteNotificationsWithError:error];
[RCTPushNotificationManager didFailToRegisterForRemoteNotificationsWithError:error];
}

// Required for the localNotification event.
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
[RCTPushNotificationManager didReceiveLocalNotification:notification];
[RCTPushNotificationManager didReceiveLocalNotification:notification];
}

@end
8 changes: 4 additions & 4 deletions client/react-native/ios/modules/core/CoreModule.m
Expand Up @@ -11,20 +11,20 @@
@interface RCT_EXTERN_REMAP_MODULE(CoreModule, CoreModule, NSObject)

RCT_EXTERN_METHOD(initialize:(RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject);
reject:(RCTPromiseRejectBlock)reject);

RCT_EXTERN_METHOD(listAccounts:(RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject);
reject:(RCTPromiseRejectBlock)reject);

RCT_EXTERN_METHOD(start:(NSString)nickname
resolve:(RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject);

RCT_EXTERN_METHOD(restart:(RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject);
reject:(RCTPromiseRejectBlock)reject);

RCT_EXTERN_METHOD(dropDatabase:(RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject);
reject:(RCTPromiseRejectBlock)reject);

RCT_EXTERN_METHOD(getPort:(RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject);
Expand Down
20 changes: 10 additions & 10 deletions core/cmd/berty/banner.go
@@ -1,14 +1,14 @@
package main

const banner = `
/\
/\ / /\ ______
/ /\/ / \/ | \
▏▕ \/ ▕ ()| |
\ \ ▕ |____|
\ \ \____/ __ __
\/ / / / ___ ____/ /___ __
/ __/ / _ \/ -_) __/ __/ // /
/_____/ /____/\__/_/ \__/\__ /
/__/ /___/
/\
/\ / /\ ______
/ /\/ / \/ | \
▏▕ \/ ▕ ()| |
\ \ ▕ |____|
\ \ \____/ __ __
\/ / / / ___ ____/ /___ __
/ __/ / _ \/ -_) __/ __/ // /
/_____/ /____/\__/_/ \__/\__ /
/__/ /___/
`
8 changes: 4 additions & 4 deletions core/crypto/enclave/enclave_test.go
Expand Up @@ -34,7 +34,7 @@ func TestEnclave(t *testing.T) {

// the keypair should satisfy keypair.Interface and return a valid pubkey
sc := sigchain.SigChain{}
So(sc.Init(kp, "Test1"), ShouldBeNil)
So(sc.Init(kp, []byte("Test1")), ShouldBeNil)
pub, err := kp.GetPubKey()
So(err, ShouldBeNil)
So(verifyPubKey(pub), ShouldBeNil)
Expand All @@ -52,7 +52,7 @@ func TestEnclave(t *testing.T) {

// the keypair should satisfy keypair.Interface and return a valid pubkey
sc := sigchain.SigChain{}
So(sc.Init(kp, "Test1"), ShouldBeNil)
So(sc.Init(kp, []byte("Test1")), ShouldBeNil)
pub, err := kp.GetPubKey()
So(err, ShouldBeNil)
So(verifyPubKey(pub), ShouldBeNil)
Expand All @@ -69,7 +69,7 @@ func TestEnclave(t *testing.T) {
So(kp.PublicKeyAlgorithm(), ShouldEqual, keypair.PublicKeyAlgorithm_RSA)
So(kp.SignatureAlgorithm(), ShouldEqual, keypair.SignatureAlgorithm_SHA512_WITH_RSA)
sc := sigchain.SigChain{}
So(sc.Init(kp, "Test1"), ShouldBeNil)
So(sc.Init(kp, []byte("Test1")), ShouldBeNil)
pub, err := kp.GetPubKey()
So(err, ShouldBeNil)
So(verifyPubKey(pub), ShouldBeNil)
Expand All @@ -91,7 +91,7 @@ func TestEnclave(t *testing.T) {
So(kp.PublicKeyAlgorithm(), ShouldEqual, keypair.PublicKeyAlgorithm_RSA)
So(kp.SignatureAlgorithm(), ShouldEqual, keypair.SignatureAlgorithm_SHA512_WITH_RSA)
sc := sigchain.SigChain{}
So(sc.Init(kp, "Test1"), ShouldBeNil)
So(sc.Init(kp, []byte("Test1")), ShouldBeNil)
pub, err := kp.GetPubKey()
So(err, ShouldBeNil)
So(verifyPubKey(pub), ShouldBeNil)
Expand Down
8 changes: 4 additions & 4 deletions core/crypto/keypair/keypair.go
Expand Up @@ -61,8 +61,8 @@ func (m *CertificateContent) GetDataToSign() ([]byte, error) {
m.Extension,
m.PublicKey,
IntToBytes(uint64(m.PublicKeyAlgorithm)),
[]byte(m.Issuer),
[]byte(m.Subject),
m.Issuer,
m.Subject,
IntToBytes(uint64(m.NotBefore.UnixNano())),
IntToBytes(uint64(m.NotAfter.UnixNano())),
}, []byte("")), nil
Expand All @@ -71,8 +71,8 @@ func (m *CertificateContent) GetDataToSign() ([]byte, error) {
func (m *RevocationContent) GetDataToSign() ([]byte, error) {
return bytes.Join([][]byte{
m.Extension,
[]byte(m.Issuer),
[]byte(m.Subject),
m.Issuer,
m.Subject,
IntToBytes(uint64(m.IssuedOn.UnixNano())),
}, []byte("")), nil
}
Expand Down
42 changes: 21 additions & 21 deletions core/crypto/sigchain/sigchain_test.go
Expand Up @@ -44,19 +44,19 @@ func TestFlow(t *testing.T) {
}

sc := SigChain{}
err = sc.Init(&cryptoImpl, "Test1")
err = sc.Init(&cryptoImpl, []byte("Test1"))

if err != nil {
t.Errorf("unable to init sigchain : %s", err)
}

err = sc.AddDevice(&cryptoImpl, "Test1", "Test2", pubBytes2)
err = sc.AddDevice(&cryptoImpl, []byte("Test1"), []byte("Test2"), pubBytes2)

if err != nil {
t.Errorf("unable to add device %s", err)
}

err = sc.RemoveDevice(&cryptoImpl, "Test1", "Test2")
err = sc.RemoveDevice(&cryptoImpl, []byte("Test1"), []byte("Test2"))

if err != nil {
t.Errorf("unable to remove device %s", err)
Expand All @@ -74,7 +74,7 @@ func TestFlow(t *testing.T) {
}

func TestInit(t *testing.T) {
firstDevice := "Test1"
firstDevice := []byte("Test1")

p, _ := rsa.GenerateKey(rand.Reader, 2048)
privBytes, _ := x509.MarshalPKCS8PrivateKey(p)
Expand All @@ -91,22 +91,22 @@ func TestInit(t *testing.T) {
t.Errorf("wrong number of devices %d expected %d received", len(devices), 1)
}

if devices[firstDevice].Content.Issuer != firstDevice {
t.Errorf("issuer is not self device received: %s expected %s", devices[firstDevice].Content.Issuer, firstDevice)
if !bytes.Equal(devices[string(firstDevice)].Content.Issuer, firstDevice) {
t.Errorf("issuer is not self device received: %s expected %s", devices[string(firstDevice)].Content.Issuer, firstDevice)
}

if devices[firstDevice].Content.Subject != firstDevice {
t.Errorf("subject is not self device received: %s expected %s", devices[firstDevice].Content.Subject, firstDevice)
if !bytes.Equal(devices[string(firstDevice)].Content.Subject, firstDevice) {
t.Errorf("subject is not self device received: %s expected %s", devices[string(firstDevice)].Content.Subject, firstDevice)
}

if bytes.Compare(devices[firstDevice].Content.PublicKey, pubBytes) != 0 {
if bytes.Compare(devices[string(firstDevice)].Content.PublicKey, pubBytes) != 0 {
t.Errorf("public key not included in certificate")
}
}

func TestAdd(t *testing.T) {
firstDevice := "Test1"
secondDevice := "Test2"
firstDevice := []byte("Test1")
secondDevice := []byte("Test2")

p, _ := rsa.GenerateKey(rand.Reader, 2048)
privByte, _ := x509.MarshalPKCS8PrivateKey(p)
Expand All @@ -127,22 +127,22 @@ func TestAdd(t *testing.T) {
t.Errorf("wrong number of devices %d expected %d received", len(devices), 2)
}

if devices[secondDevice].Content.Issuer != firstDevice {
t.Errorf("issuer is not self device received: %s expected %s", devices[secondDevice].Content.Issuer, firstDevice)
if !bytes.Equal(devices[string(secondDevice)].Content.Issuer, firstDevice) {
t.Errorf("issuer is not self device received: %s expected %s", devices[string(secondDevice)].Content.Issuer, firstDevice)
}

if devices[secondDevice].Content.Subject != secondDevice {
t.Errorf("subject is not self device received: %s expected %s", devices[secondDevice].Content.Subject, secondDevice)
if !bytes.Equal(devices[string(secondDevice)].Content.Subject, secondDevice) {
t.Errorf("subject is not self device received: %s expected %s", devices[string(secondDevice)].Content.Subject, secondDevice)
}

if bytes.Compare(devices[secondDevice].Content.PublicKey, pub2Byte) != 0 {
if bytes.Compare(devices[string(secondDevice)].Content.PublicKey, pub2Byte) != 0 {
t.Errorf("public key not included in certificate")
}
}

func TestRemove(t *testing.T) {
firstDevice := "Test1"
secondDevice := "Test2"
firstDevice := []byte("Test1")
secondDevice := []byte("Test2")

p, _ := rsa.GenerateKey(rand.Reader, 2048)
privByte, _ := x509.MarshalPKCS8PrivateKey(p)
Expand All @@ -164,13 +164,13 @@ func TestRemove(t *testing.T) {
t.Errorf("wrong number of devices %d expected %d received", len(devices), 1)
}

if _, ok := devices[secondDevice]; ok == true {
if _, ok := devices[string(secondDevice)]; ok == true {
t.Errorf("second device should not be present")
}
}

func TestCertificateCheckSignature(t *testing.T) {
firstDevice := "Test1"
firstDevice := []byte("Test1")

p, _ := rsa.GenerateKey(rand.Reader, 2048)
privBytes, _ := x509.MarshalPKCS8PrivateKey(p)
Expand All @@ -196,7 +196,7 @@ func TestCertificateCheckSignature(t *testing.T) {
}

func TestRevocationCheckSignature(t *testing.T) {
firstDevice := "Test1"
firstDevice := []byte("Test1")

p, _ := rsa.GenerateKey(rand.Reader, 2048)
privBytes, _ := x509.MarshalPKCS8PrivateKey(p)
Expand Down
1 change: 1 addition & 0 deletions core/go.mod
Expand Up @@ -136,6 +136,7 @@ require (
go.uber.org/multierr v1.1.0 // indirect
go.uber.org/zap v1.9.1
golang.org/x/crypto v0.0.0-20181015023909-0c41d7ab0a0e // indirect
golang.org/x/net v0.0.0-20181011144130-49bb7cea24b1
golang.org/x/sys v0.0.0-20181011152604-fa43e7bc11ba // indirect
google.golang.org/appengine v1.2.0 // indirect
google.golang.org/genproto v0.0.0-20181004005441-af9cb2a35e7f // indirect
Expand Down
1 change: 0 additions & 1 deletion core/network/ble/darwin.go
Expand Up @@ -9,7 +9,6 @@ import (
"unsafe"

peer "github.com/libp2p/go-libp2p-peer"

tpt "github.com/libp2p/go-libp2p-transport"
ma "github.com/multiformats/go-multiaddr"
"go.uber.org/zap"
Expand Down

0 comments on commit e4c3222

Please sign in to comment.